documentation.d.ts 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823
  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. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module BABYLON {
  480. /**
  481. * File request interface
  482. */
  483. export interface IFileRequest {
  484. /**
  485. * Raised when the request is complete (success or error).
  486. */
  487. onCompleteObservable: Observable<IFileRequest>;
  488. /**
  489. * Aborts the request for a file.
  490. */
  491. abort: () => void;
  492. }
  493. }
  494. declare module BABYLON {
  495. /**
  496. * Scalar computation library
  497. */
  498. export class Scalar {
  499. /**
  500. * Two pi constants convenient for computation.
  501. */
  502. static TwoPi: number;
  503. /**
  504. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  505. * @param a number
  506. * @param b number
  507. * @param epsilon (default = 1.401298E-45)
  508. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  509. */
  510. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  511. /**
  512. * Returns a string : the upper case translation of the number i to hexadecimal.
  513. * @param i number
  514. * @returns the upper case translation of the number i to hexadecimal.
  515. */
  516. static ToHex(i: number): string;
  517. /**
  518. * Returns -1 if value is negative and +1 is value is positive.
  519. * @param value the value
  520. * @returns the value itself if it's equal to zero.
  521. */
  522. static Sign(value: number): number;
  523. /**
  524. * Returns the value itself if it's between min and max.
  525. * Returns min if the value is lower than min.
  526. * Returns max if the value is greater than max.
  527. * @param value the value to clmap
  528. * @param min the min value to clamp to (default: 0)
  529. * @param max the max value to clamp to (default: 1)
  530. * @returns the clamped value
  531. */
  532. static Clamp(value: number, min?: number, max?: number): number;
  533. /**
  534. * the log2 of value.
  535. * @param value the value to compute log2 of
  536. * @returns the log2 of value.
  537. */
  538. static Log2(value: number): number;
  539. /**
  540. * Loops the value, so that it is never larger than length and never smaller than 0.
  541. *
  542. * This is similar to the modulo operator but it works with floating point numbers.
  543. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  544. * With t = 5 and length = 2.5, the result would be 0.0.
  545. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  546. * @param value the value
  547. * @param length the length
  548. * @returns the looped value
  549. */
  550. static Repeat(value: number, length: number): number;
  551. /**
  552. * Normalize the value between 0.0 and 1.0 using min and max values
  553. * @param value value to normalize
  554. * @param min max to normalize between
  555. * @param max min to normalize between
  556. * @returns the normalized value
  557. */
  558. static Normalize(value: number, min: number, max: number): number;
  559. /**
  560. * Denormalize the value from 0.0 and 1.0 using min and max values
  561. * @param normalized value to denormalize
  562. * @param min max to denormalize between
  563. * @param max min to denormalize between
  564. * @returns the denormalized value
  565. */
  566. static Denormalize(normalized: number, min: number, max: number): number;
  567. /**
  568. * Calculates the shortest difference between two given angles given in degrees.
  569. * @param current current angle in degrees
  570. * @param target target angle in degrees
  571. * @returns the delta
  572. */
  573. static DeltaAngle(current: number, target: number): number;
  574. /**
  575. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  576. * @param tx value
  577. * @param length length
  578. * @returns The returned value will move back and forth between 0 and length
  579. */
  580. static PingPong(tx: number, length: number): number;
  581. /**
  582. * Interpolates between min and max with smoothing at the limits.
  583. *
  584. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  585. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  586. * @param from from
  587. * @param to to
  588. * @param tx value
  589. * @returns the smooth stepped value
  590. */
  591. static SmoothStep(from: number, to: number, tx: number): number;
  592. /**
  593. * Moves a value current towards target.
  594. *
  595. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  596. * Negative values of maxDelta pushes the value away from target.
  597. * @param current current value
  598. * @param target target value
  599. * @param maxDelta max distance to move
  600. * @returns resulting value
  601. */
  602. static MoveTowards(current: number, target: number, maxDelta: number): number;
  603. /**
  604. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  605. *
  606. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  607. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  608. * @param current current value
  609. * @param target target value
  610. * @param maxDelta max distance to move
  611. * @returns resulting angle
  612. */
  613. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  614. /**
  615. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  616. * @param start start value
  617. * @param end target value
  618. * @param amount amount to lerp between
  619. * @returns the lerped value
  620. */
  621. static Lerp(start: number, end: number, amount: number): number;
  622. /**
  623. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  624. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  625. * @param start start value
  626. * @param end target value
  627. * @param amount amount to lerp between
  628. * @returns the lerped value
  629. */
  630. static LerpAngle(start: number, end: number, amount: number): number;
  631. /**
  632. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  633. * @param a start value
  634. * @param b target value
  635. * @param value value between a and b
  636. * @returns the inverseLerp value
  637. */
  638. static InverseLerp(a: number, b: number, value: number): number;
  639. /**
  640. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  641. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  642. * @param value1 spline value
  643. * @param tangent1 spline value
  644. * @param value2 spline value
  645. * @param tangent2 spline value
  646. * @param amount input value
  647. * @returns hermite result
  648. */
  649. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  650. /**
  651. * Returns a random float number between and min and max values
  652. * @param min min value of random
  653. * @param max max value of random
  654. * @returns random value
  655. */
  656. static RandomRange(min: number, max: number): number;
  657. /**
  658. * This function returns percentage of a number in a given range.
  659. *
  660. * RangeToPercent(40,20,60) will return 0.5 (50%)
  661. * RangeToPercent(34,0,100) will return 0.34 (34%)
  662. * @param number to convert to percentage
  663. * @param min min range
  664. * @param max max range
  665. * @returns the percentage
  666. */
  667. static RangeToPercent(number: number, min: number, max: number): number;
  668. /**
  669. * This function returns number that corresponds to the percentage in a given range.
  670. *
  671. * PercentToRange(0.34,0,100) will return 34.
  672. * @param percent to convert to number
  673. * @param min min range
  674. * @param max max range
  675. * @returns the number
  676. */
  677. static PercentToRange(percent: number, min: number, max: number): number;
  678. /**
  679. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  680. * @param angle The angle to normalize in radian.
  681. * @return The converted angle.
  682. */
  683. static NormalizeRadians(angle: number): number;
  684. }
  685. }
  686. declare module BABYLON {
  687. /**
  688. * Constant used to convert a value to gamma space
  689. * @ignorenaming
  690. */
  691. export const ToGammaSpace: number;
  692. /**
  693. * Constant used to convert a value to linear space
  694. * @ignorenaming
  695. */
  696. export const ToLinearSpace = 2.2;
  697. /**
  698. * Constant used to define the minimal number value in Babylon.js
  699. * @ignorenaming
  700. */
  701. let Epsilon: number;
  702. }
  703. declare module BABYLON {
  704. /**
  705. * Class used to represent a viewport on screen
  706. */
  707. export class Viewport {
  708. /** viewport left coordinate */
  709. x: number;
  710. /** viewport top coordinate */
  711. y: number;
  712. /**viewport width */
  713. width: number;
  714. /** viewport height */
  715. height: number;
  716. /**
  717. * Creates a Viewport object located at (x, y) and sized (width, height)
  718. * @param x defines viewport left coordinate
  719. * @param y defines viewport top coordinate
  720. * @param width defines the viewport width
  721. * @param height defines the viewport height
  722. */
  723. constructor(
  724. /** viewport left coordinate */
  725. x: number,
  726. /** viewport top coordinate */
  727. y: number,
  728. /**viewport width */
  729. width: number,
  730. /** viewport height */
  731. height: number);
  732. /**
  733. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  734. * @param renderWidth defines the rendering width
  735. * @param renderHeight defines the rendering height
  736. * @returns a new Viewport
  737. */
  738. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  739. /**
  740. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  741. * @param renderWidth defines the rendering width
  742. * @param renderHeight defines the rendering height
  743. * @param ref defines the target viewport
  744. * @returns the current viewport
  745. */
  746. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  747. /**
  748. * Returns a new Viewport copied from the current one
  749. * @returns a new Viewport
  750. */
  751. clone(): Viewport;
  752. }
  753. }
  754. declare module BABYLON {
  755. /**
  756. * Class containing a set of static utilities functions for arrays.
  757. */
  758. export class ArrayTools {
  759. /**
  760. * Returns an array of the given size filled with element built from the given constructor and the paramters
  761. * @param size the number of element to construct and put in the array
  762. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  763. * @returns a new array filled with new objects
  764. */
  765. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  766. }
  767. }
  768. declare module BABYLON {
  769. /**
  770. * @hidden
  771. */
  772. export interface IColor4Like {
  773. r: float;
  774. g: float;
  775. b: float;
  776. a: float;
  777. }
  778. /**
  779. * @hidden
  780. */
  781. export interface IColor3Like {
  782. r: float;
  783. g: float;
  784. b: float;
  785. }
  786. /**
  787. * @hidden
  788. */
  789. export interface IVector4Like {
  790. x: float;
  791. y: float;
  792. z: float;
  793. w: float;
  794. }
  795. /**
  796. * @hidden
  797. */
  798. export interface IVector3Like {
  799. x: float;
  800. y: float;
  801. z: float;
  802. }
  803. /**
  804. * @hidden
  805. */
  806. export interface IVector2Like {
  807. x: float;
  808. y: float;
  809. }
  810. /**
  811. * @hidden
  812. */
  813. export interface IMatrixLike {
  814. toArray(): DeepImmutable<Float32Array>;
  815. updateFlag: int;
  816. }
  817. /**
  818. * @hidden
  819. */
  820. export interface IViewportLike {
  821. x: float;
  822. y: float;
  823. width: float;
  824. height: float;
  825. }
  826. /**
  827. * @hidden
  828. */
  829. export interface IPlaneLike {
  830. normal: IVector3Like;
  831. d: float;
  832. normalize(): void;
  833. }
  834. }
  835. declare module BABYLON {
  836. /**
  837. * Class representing a vector containing 2 coordinates
  838. */
  839. export class Vector2 {
  840. /** defines the first coordinate */
  841. x: number;
  842. /** defines the second coordinate */
  843. y: number;
  844. /**
  845. * Creates a new Vector2 from the given x and y coordinates
  846. * @param x defines the first coordinate
  847. * @param y defines the second coordinate
  848. */
  849. constructor(
  850. /** defines the first coordinate */
  851. x?: number,
  852. /** defines the second coordinate */
  853. y?: number);
  854. /**
  855. * Gets a string with the Vector2 coordinates
  856. * @returns a string with the Vector2 coordinates
  857. */
  858. toString(): string;
  859. /**
  860. * Gets class name
  861. * @returns the string "Vector2"
  862. */
  863. getClassName(): string;
  864. /**
  865. * Gets current vector hash code
  866. * @returns the Vector2 hash code as a number
  867. */
  868. getHashCode(): number;
  869. /**
  870. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  871. * @param array defines the source array
  872. * @param index defines the offset in source array
  873. * @returns the current Vector2
  874. */
  875. toArray(array: FloatArray, index?: number): Vector2;
  876. /**
  877. * Copy the current vector to an array
  878. * @returns a new array with 2 elements: the Vector2 coordinates.
  879. */
  880. asArray(): number[];
  881. /**
  882. * Sets the Vector2 coordinates with the given Vector2 coordinates
  883. * @param source defines the source Vector2
  884. * @returns the current updated Vector2
  885. */
  886. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  887. /**
  888. * Sets the Vector2 coordinates with the given floats
  889. * @param x defines the first coordinate
  890. * @param y defines the second coordinate
  891. * @returns the current updated Vector2
  892. */
  893. copyFromFloats(x: number, y: number): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. set(x: number, y: number): Vector2;
  901. /**
  902. * Add another vector with the current one
  903. * @param otherVector defines the other vector
  904. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  905. */
  906. add(otherVector: DeepImmutable<Vector2>): Vector2;
  907. /**
  908. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  909. * @param otherVector defines the other vector
  910. * @param result defines the target vector
  911. * @returns the unmodified current Vector2
  912. */
  913. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  914. /**
  915. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  916. * @param otherVector defines the other vector
  917. * @returns the current updated Vector2
  918. */
  919. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  920. /**
  921. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. addVector3(otherVector: Vector3): Vector2;
  926. /**
  927. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  928. * @param otherVector defines the other vector
  929. * @returns a new Vector2
  930. */
  931. subtract(otherVector: Vector2): Vector2;
  932. /**
  933. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  934. * @param otherVector defines the other vector
  935. * @param result defines the target vector
  936. * @returns the unmodified current Vector2
  937. */
  938. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  939. /**
  940. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Multiplies in place the current Vector2 coordinates by the given ones
  947. * @param otherVector defines the other vector
  948. * @returns the current updated Vector2
  949. */
  950. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns a new Vector2
  955. */
  956. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  959. * @param otherVector defines the other vector
  960. * @param result defines the target vector
  961. * @returns the unmodified current Vector2
  962. */
  963. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  964. /**
  965. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  966. * @param x defines the first coordinate
  967. * @param y defines the second coordinate
  968. * @returns a new Vector2
  969. */
  970. multiplyByFloats(x: number, y: number): Vector2;
  971. /**
  972. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @returns a new Vector2
  975. */
  976. divide(otherVector: Vector2): Vector2;
  977. /**
  978. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  979. * @param otherVector defines the other vector
  980. * @param result defines the target vector
  981. * @returns the unmodified current Vector2
  982. */
  983. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  984. /**
  985. * Divides the current Vector2 coordinates by the given ones
  986. * @param otherVector defines the other vector
  987. * @returns the current updated Vector2
  988. */
  989. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  990. /**
  991. * Gets a new Vector2 with current Vector2 negated coordinates
  992. * @returns a new Vector2
  993. */
  994. negate(): Vector2;
  995. /**
  996. * Multiply the Vector2 coordinates by scale
  997. * @param scale defines the scaling factor
  998. * @returns the current updated Vector2
  999. */
  1000. scaleInPlace(scale: number): Vector2;
  1001. /**
  1002. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1003. * @param scale defines the scaling factor
  1004. * @returns a new Vector2
  1005. */
  1006. scale(scale: number): Vector2;
  1007. /**
  1008. * Scale the current Vector2 values by a factor to a given Vector2
  1009. * @param scale defines the scale factor
  1010. * @param result defines the Vector2 object where to store the result
  1011. * @returns the unmodified current Vector2
  1012. */
  1013. scaleToRef(scale: number, result: Vector2): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Gets a boolean if two vectors are equals
  1023. * @param otherVector defines the other vector
  1024. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1025. */
  1026. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1027. /**
  1028. * Gets a boolean if two vectors are equals (using an epsilon value)
  1029. * @param otherVector defines the other vector
  1030. * @param epsilon defines the minimal distance to consider equality
  1031. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1032. */
  1033. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1034. /**
  1035. * Gets a new Vector2 from current Vector2 floored values
  1036. * @returns a new Vector2
  1037. */
  1038. floor(): Vector2;
  1039. /**
  1040. * Gets a new Vector2 from current Vector2 floored values
  1041. * @returns a new Vector2
  1042. */
  1043. fract(): Vector2;
  1044. /**
  1045. * Gets the length of the vector
  1046. * @returns the vector length (float)
  1047. */
  1048. length(): number;
  1049. /**
  1050. * Gets the vector squared length
  1051. * @returns the vector squared length (float)
  1052. */
  1053. lengthSquared(): number;
  1054. /**
  1055. * Normalize the vector
  1056. * @returns the current updated Vector2
  1057. */
  1058. normalize(): Vector2;
  1059. /**
  1060. * Gets a new Vector2 copied from the Vector2
  1061. * @returns a new Vector2
  1062. */
  1063. clone(): Vector2;
  1064. /**
  1065. * Gets a new Vector2(0, 0)
  1066. * @returns a new Vector2
  1067. */
  1068. static Zero(): Vector2;
  1069. /**
  1070. * Gets a new Vector2(1, 1)
  1071. * @returns a new Vector2
  1072. */
  1073. static One(): Vector2;
  1074. /**
  1075. * Gets a new Vector2 set from the given index element of the given array
  1076. * @param array defines the data source
  1077. * @param offset defines the offset in the data source
  1078. * @returns a new Vector2
  1079. */
  1080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1081. /**
  1082. * Sets "result" from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @param result defines the target vector
  1086. */
  1087. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1088. /**
  1089. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1090. * @param value1 defines 1st point of control
  1091. * @param value2 defines 2nd point of control
  1092. * @param value3 defines 3rd point of control
  1093. * @param value4 defines 4th point of control
  1094. * @param amount defines the interpolation factor
  1095. * @returns a new Vector2
  1096. */
  1097. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1098. /**
  1099. * 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".
  1100. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1101. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1102. * @param value defines the value to clamp
  1103. * @param min defines the lower limit
  1104. * @param max defines the upper limit
  1105. * @returns a new Vector2
  1106. */
  1107. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1108. /**
  1109. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1110. * @param value1 defines the 1st control point
  1111. * @param tangent1 defines the outgoing tangent
  1112. * @param value2 defines the 2nd control point
  1113. * @param tangent2 defines the incoming tangent
  1114. * @param amount defines the interpolation factor
  1115. * @returns a new Vector2
  1116. */
  1117. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1118. /**
  1119. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1120. * @param start defines the start vector
  1121. * @param end defines the end vector
  1122. * @param amount defines the interpolation factor
  1123. * @returns a new Vector2
  1124. */
  1125. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1126. /**
  1127. * Gets the dot product of the vector "left" and the vector "right"
  1128. * @param left defines first vector
  1129. * @param right defines second vector
  1130. * @returns the dot product (float)
  1131. */
  1132. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1133. /**
  1134. * Returns a new Vector2 equal to the normalized given vector
  1135. * @param vector defines the vector to normalize
  1136. * @returns a new Vector2
  1137. */
  1138. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1139. /**
  1140. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1141. * @param left defines 1st vector
  1142. * @param right defines 2nd vector
  1143. * @returns a new Vector2
  1144. */
  1145. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1155. * @param vector defines the vector to transform
  1156. * @param transformation defines the matrix to apply
  1157. * @returns a new Vector2
  1158. */
  1159. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1160. /**
  1161. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @param result defines the target vector
  1165. */
  1166. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1167. /**
  1168. * Determines if a given vector is included in a triangle
  1169. * @param p defines the vector to test
  1170. * @param p0 defines 1st triangle point
  1171. * @param p1 defines 2nd triangle point
  1172. * @param p2 defines 3rd triangle point
  1173. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1174. */
  1175. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1176. /**
  1177. * Gets the distance between the vectors "value1" and "value2"
  1178. * @param value1 defines first vector
  1179. * @param value2 defines second vector
  1180. * @returns the distance between vectors
  1181. */
  1182. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1183. /**
  1184. * Returns the squared distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the squared distance between vectors
  1188. */
  1189. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns a new Vector2
  1195. */
  1196. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1197. /**
  1198. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1199. * @param p defines the middle point
  1200. * @param segA defines one point of the segment
  1201. * @param segB defines the other point of the segment
  1202. * @returns the shortest distance
  1203. */
  1204. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1205. }
  1206. /**
  1207. * Classed used to store (x,y,z) vector representation
  1208. * A Vector3 is the main object used in 3D geometry
  1209. * It can represent etiher the coordinates of a point the space, either a direction
  1210. * Reminder: js uses a left handed forward facing system
  1211. */
  1212. export class Vector3 {
  1213. /**
  1214. * Defines the first coordinates (on X axis)
  1215. */
  1216. x: number;
  1217. /**
  1218. * Defines the second coordinates (on Y axis)
  1219. */
  1220. y: number;
  1221. /**
  1222. * Defines the third coordinates (on Z axis)
  1223. */
  1224. z: number;
  1225. private static _UpReadOnly;
  1226. private static _ZeroReadOnly;
  1227. /**
  1228. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1229. * @param x defines the first coordinates (on X axis)
  1230. * @param y defines the second coordinates (on Y axis)
  1231. * @param z defines the third coordinates (on Z axis)
  1232. */
  1233. constructor(
  1234. /**
  1235. * Defines the first coordinates (on X axis)
  1236. */
  1237. x?: number,
  1238. /**
  1239. * Defines the second coordinates (on Y axis)
  1240. */
  1241. y?: number,
  1242. /**
  1243. * Defines the third coordinates (on Z axis)
  1244. */
  1245. z?: number);
  1246. /**
  1247. * Creates a string representation of the Vector3
  1248. * @returns a string with the Vector3 coordinates.
  1249. */
  1250. toString(): string;
  1251. /**
  1252. * Gets the class name
  1253. * @returns the string "Vector3"
  1254. */
  1255. getClassName(): string;
  1256. /**
  1257. * Creates the Vector3 hash code
  1258. * @returns a number which tends to be unique between Vector3 instances
  1259. */
  1260. getHashCode(): number;
  1261. /**
  1262. * Creates an array containing three elements : the coordinates of the Vector3
  1263. * @returns a new array of numbers
  1264. */
  1265. asArray(): number[];
  1266. /**
  1267. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1268. * @param array defines the destination array
  1269. * @param index defines the offset in the destination array
  1270. * @returns the current Vector3
  1271. */
  1272. toArray(array: FloatArray, index?: number): Vector3;
  1273. /**
  1274. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1275. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1276. */
  1277. toQuaternion(): Quaternion;
  1278. /**
  1279. * Adds the given vector to the current Vector3
  1280. * @param otherVector defines the second operand
  1281. * @returns the current updated Vector3
  1282. */
  1283. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1284. /**
  1285. * Adds the given coordinates to the current Vector3
  1286. * @param x defines the x coordinate of the operand
  1287. * @param y defines the y coordinate of the operand
  1288. * @param z defines the z coordinate of the operand
  1289. * @returns the current updated Vector3
  1290. */
  1291. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1292. /**
  1293. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1294. * @param otherVector defines the second operand
  1295. * @returns the resulting Vector3
  1296. */
  1297. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1300. * @param otherVector defines the second operand
  1301. * @param result defines the Vector3 object where to store the result
  1302. * @returns the current Vector3
  1303. */
  1304. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1305. /**
  1306. * Subtract the given vector from the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the current updated Vector3
  1309. */
  1310. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1313. * @param otherVector defines the second operand
  1314. * @returns the resulting Vector3
  1315. */
  1316. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1317. /**
  1318. * Subtracts the given vector from the current Vector3 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. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1324. /**
  1325. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1326. * @param x defines the x coordinate of the operand
  1327. * @param y defines the y coordinate of the operand
  1328. * @param z defines the z coordinate of the operand
  1329. * @returns the resulting Vector3
  1330. */
  1331. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1332. /**
  1333. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1334. * @param x defines the x coordinate of the operand
  1335. * @param y defines the y coordinate of the operand
  1336. * @param z defines the z coordinate of the operand
  1337. * @param result defines the Vector3 object where to store the result
  1338. * @returns the current Vector3
  1339. */
  1340. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1341. /**
  1342. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1343. * @returns a new Vector3
  1344. */
  1345. negate(): Vector3;
  1346. /**
  1347. * Multiplies the Vector3 coordinates by the float "scale"
  1348. * @param scale defines the multiplier factor
  1349. * @returns the current updated Vector3
  1350. */
  1351. scaleInPlace(scale: number): Vector3;
  1352. /**
  1353. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1354. * @param scale defines the multiplier factor
  1355. * @returns a new Vector3
  1356. */
  1357. scale(scale: number): Vector3;
  1358. /**
  1359. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1360. * @param scale defines the multiplier factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the current Vector3
  1363. */
  1364. scaleToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1367. * @param scale defines the scale factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the unmodified current Vector3
  1370. */
  1371. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1374. * @param otherVector defines the second operand
  1375. * @returns true if both vectors are equals
  1376. */
  1377. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1380. * @param otherVector defines the second operand
  1381. * @param epsilon defines the minimal distance to define values as equals
  1382. * @returns true if both vectors are distant less than epsilon
  1383. */
  1384. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 coordinates equals the given floats
  1387. * @param x defines the x coordinate of the operand
  1388. * @param y defines the y coordinate of the operand
  1389. * @param z defines the z coordinate of the operand
  1390. * @returns true if both vectors are equals
  1391. */
  1392. equalsToFloats(x: number, y: number, z: number): boolean;
  1393. /**
  1394. * Multiplies the current Vector3 coordinates by the given ones
  1395. * @param otherVector defines the second operand
  1396. * @returns the current updated Vector3
  1397. */
  1398. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1399. /**
  1400. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1401. * @param otherVector defines the second operand
  1402. * @returns the new Vector3
  1403. */
  1404. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1405. /**
  1406. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1407. * @param otherVector defines the second operand
  1408. * @param result defines the Vector3 object where to store the result
  1409. * @returns the current Vector3
  1410. */
  1411. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1412. /**
  1413. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1414. * @param x defines the x coordinate of the operand
  1415. * @param y defines the y coordinate of the operand
  1416. * @param z defines the z coordinate of the operand
  1417. * @returns the new Vector3
  1418. */
  1419. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1420. /**
  1421. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1422. * @param otherVector defines the second operand
  1423. * @returns the new Vector3
  1424. */
  1425. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1428. * @param otherVector defines the second operand
  1429. * @param result defines the Vector3 object where to store the result
  1430. * @returns the current Vector3
  1431. */
  1432. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones.
  1435. * @param otherVector defines the second operand
  1436. * @returns the current updated Vector3
  1437. */
  1438. divideInPlace(otherVector: Vector3): Vector3;
  1439. /**
  1440. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1441. * @param other defines the second operand
  1442. * @returns the current updated Vector3
  1443. */
  1444. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1445. /**
  1446. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1447. * @param other defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1453. * @param x defines the x coordinate of the operand
  1454. * @param y defines the y coordinate of the operand
  1455. * @param z defines the z coordinate of the operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1461. * @param x defines the x coordinate of the operand
  1462. * @param y defines the y coordinate of the operand
  1463. * @param z defines the z coordinate of the operand
  1464. * @returns the current updated Vector3
  1465. */
  1466. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1467. /**
  1468. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1469. * Check if is non uniform within a certain amount of decimal places to account for this
  1470. * @param epsilon the amount the values can differ
  1471. * @returns if the the vector is non uniform to a certain number of decimal places
  1472. */
  1473. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1474. /**
  1475. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1476. */
  1477. readonly isNonUniform: boolean;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. floor(): Vector3;
  1483. /**
  1484. * Gets a new Vector3 from current Vector3 floored values
  1485. * @returns a new Vector3
  1486. */
  1487. fract(): Vector3;
  1488. /**
  1489. * Gets the length of the Vector3
  1490. * @returns the length of the Vector3
  1491. */
  1492. length(): number;
  1493. /**
  1494. * Gets the squared length of the Vector3
  1495. * @returns squared length of the Vector3
  1496. */
  1497. lengthSquared(): number;
  1498. /**
  1499. * Normalize the current Vector3.
  1500. * Please note that this is an in place operation.
  1501. * @returns the current updated Vector3
  1502. */
  1503. normalize(): Vector3;
  1504. /**
  1505. * Reorders the x y z properties of the vector in place
  1506. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1507. * @returns the current updated vector
  1508. */
  1509. reorderInPlace(order: string): this;
  1510. /**
  1511. * Rotates the vector around 0,0,0 by a quaternion
  1512. * @param quaternion the rotation quaternion
  1513. * @param result vector to store the result
  1514. * @returns the resulting vector
  1515. */
  1516. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1517. /**
  1518. * Rotates a vector around a given point
  1519. * @param quaternion the rotation quaternion
  1520. * @param point the point to rotate around
  1521. * @param result vector to store the result
  1522. * @returns the resulting vector
  1523. */
  1524. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1525. /**
  1526. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1527. * The cross product is then orthogonal to both current and "other"
  1528. * @param other defines the right operand
  1529. * @returns the cross product
  1530. */
  1531. cross(other: Vector3): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 with the given input length.
  1534. * Please note that this is an in place operation.
  1535. * @param len the length of the vector
  1536. * @returns the current updated Vector3
  1537. */
  1538. normalizeFromLength(len: number): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 to a new vector
  1541. * @returns the new Vector3
  1542. */
  1543. normalizeToNew(): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to the reference
  1546. * @param reference define the Vector3 to update
  1547. * @returns the updated Vector3
  1548. */
  1549. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1550. /**
  1551. * Creates a new Vector3 copied from the current Vector3
  1552. * @returns the new Vector3
  1553. */
  1554. clone(): Vector3;
  1555. /**
  1556. * Copies the given vector coordinates to the current Vector3 ones
  1557. * @param source defines the source Vector3
  1558. * @returns the current updated Vector3
  1559. */
  1560. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1561. /**
  1562. * Copies the given floats to the current Vector3 coordinates
  1563. * @param x defines the x coordinate of the operand
  1564. * @param y defines the y coordinate of the operand
  1565. * @param z defines the z coordinate of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. copyFromFloats(x: number, y: number, z: number): Vector3;
  1569. /**
  1570. * Copies the given floats to the current Vector3 coordinates
  1571. * @param x defines the x coordinate of the operand
  1572. * @param y defines the y coordinate of the operand
  1573. * @param z defines the z coordinate of the operand
  1574. * @returns the current updated Vector3
  1575. */
  1576. set(x: number, y: number, z: number): Vector3;
  1577. /**
  1578. * Copies the given float to the current Vector3 coordinates
  1579. * @param v defines the x, y and z coordinates of the operand
  1580. * @returns the current updated Vector3
  1581. */
  1582. setAll(v: number): Vector3;
  1583. /**
  1584. * Get the clip factor between two vectors
  1585. * @param vector0 defines the first operand
  1586. * @param vector1 defines the second operand
  1587. * @param axis defines the axis to use
  1588. * @param size defines the size along the axis
  1589. * @returns the clip factor
  1590. */
  1591. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1592. /**
  1593. * Get angle between two vectors
  1594. * @param vector0 angle between vector0 and vector1
  1595. * @param vector1 angle between vector0 and vector1
  1596. * @param normal direction of the normal
  1597. * @return the angle between vector0 and vector1
  1598. */
  1599. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1600. /**
  1601. * Returns a new Vector3 set from the index "offset" of the given array
  1602. * @param array defines the source array
  1603. * @param offset defines the offset in the source array
  1604. * @returns the new Vector3
  1605. */
  1606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1609. * This function is deprecated. Use FromArray instead
  1610. * @param array defines the source array
  1611. * @param offset defines the offset in the source array
  1612. * @returns the new Vector3
  1613. */
  1614. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1615. /**
  1616. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @param result defines the Vector3 where to store the result
  1620. */
  1621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1624. * This function is deprecated. Use FromArrayToRef instead.
  1625. * @param array defines the source array
  1626. * @param offset defines the offset in the source array
  1627. * @param result defines the Vector3 where to store the result
  1628. */
  1629. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1630. /**
  1631. * Sets the given vector "result" with the given floats.
  1632. * @param x defines the x coordinate of the source
  1633. * @param y defines the y coordinate of the source
  1634. * @param z defines the z coordinate of the source
  1635. * @param result defines the Vector3 where to store the result
  1636. */
  1637. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1638. /**
  1639. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1640. * @returns a new empty Vector3
  1641. */
  1642. static Zero(): Vector3;
  1643. /**
  1644. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1645. * @returns a new unit Vector3
  1646. */
  1647. static One(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1650. * @returns a new up Vector3
  1651. */
  1652. static Up(): Vector3;
  1653. /**
  1654. * Gets a up Vector3 that must not be updated
  1655. */
  1656. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1657. /**
  1658. * Gets a zero Vector3 that must not be updated
  1659. */
  1660. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1661. /**
  1662. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1663. * @returns a new down Vector3
  1664. */
  1665. static Down(): Vector3;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1668. * @returns a new forward Vector3
  1669. */
  1670. static Forward(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Backward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1678. * @returns a new right Vector3
  1679. */
  1680. static Right(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1683. * @returns a new left Vector3
  1684. */
  1685. static Left(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1688. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1689. * @param vector defines the Vector3 to transform
  1690. * @param transformation defines the transformation matrix
  1691. * @returns the transformed Vector3
  1692. */
  1693. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1694. /**
  1695. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1696. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @param result defines the Vector3 where to store the result
  1700. */
  1701. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1702. /**
  1703. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1704. * This method computes tranformed coordinates only, not transformed direction vectors
  1705. * @param x define the x coordinate of the source vector
  1706. * @param y define the y coordinate of the source vector
  1707. * @param z define the z coordinate of the source vector
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param vector defines the Vector3 to transform
  1716. * @param transformation defines the transformation matrix
  1717. * @returns the new Vector3
  1718. */
  1719. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1720. /**
  1721. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1722. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1723. * @param vector defines the Vector3 to transform
  1724. * @param transformation defines the transformation matrix
  1725. * @param result defines the Vector3 where to store the result
  1726. */
  1727. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1728. /**
  1729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1730. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1731. * @param x define the x coordinate of the source vector
  1732. * @param y define the y coordinate of the source vector
  1733. * @param z define the z coordinate of the source vector
  1734. * @param transformation defines the transformation matrix
  1735. * @param result defines the Vector3 where to store the result
  1736. */
  1737. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1738. /**
  1739. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1740. * @param value1 defines the first control point
  1741. * @param value2 defines the second control point
  1742. * @param value3 defines the third control point
  1743. * @param value4 defines the fourth control point
  1744. * @param amount defines the amount on the spline to use
  1745. * @returns the new Vector3
  1746. */
  1747. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1748. /**
  1749. * 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"
  1750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1752. * @param value defines the current value
  1753. * @param min defines the lower range value
  1754. * @param max defines the upper range value
  1755. * @returns the new Vector3
  1756. */
  1757. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1758. /**
  1759. * 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"
  1760. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1761. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1762. * @param value defines the current value
  1763. * @param min defines the lower range value
  1764. * @param max defines the upper range value
  1765. * @param result defines the Vector3 where to store the result
  1766. */
  1767. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1768. /**
  1769. * Checks if a given vector is inside a specific range
  1770. * @param v defines the vector to test
  1771. * @param min defines the minimum range
  1772. * @param max defines the maximum range
  1773. */
  1774. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Class used to store quaternion data
  2363. * @see https://en.wikipedia.org/wiki/Quaternion
  2364. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2365. */
  2366. export class Quaternion {
  2367. /** defines the first component (0 by default) */
  2368. x: number;
  2369. /** defines the second component (0 by default) */
  2370. y: number;
  2371. /** defines the third component (0 by default) */
  2372. z: number;
  2373. /** defines the fourth component (1.0 by default) */
  2374. w: number;
  2375. /**
  2376. * Creates a new Quaternion from the given floats
  2377. * @param x defines the first component (0 by default)
  2378. * @param y defines the second component (0 by default)
  2379. * @param z defines the third component (0 by default)
  2380. * @param w defines the fourth component (1.0 by default)
  2381. */
  2382. constructor(
  2383. /** defines the first component (0 by default) */
  2384. x?: number,
  2385. /** defines the second component (0 by default) */
  2386. y?: number,
  2387. /** defines the third component (0 by default) */
  2388. z?: number,
  2389. /** defines the fourth component (1.0 by default) */
  2390. w?: number);
  2391. /**
  2392. * Gets a string representation for the current quaternion
  2393. * @returns a string with the Quaternion coordinates
  2394. */
  2395. toString(): string;
  2396. /**
  2397. * Gets the class name of the quaternion
  2398. * @returns the string "Quaternion"
  2399. */
  2400. getClassName(): string;
  2401. /**
  2402. * Gets a hash code for this quaternion
  2403. * @returns the quaternion hash code
  2404. */
  2405. getHashCode(): number;
  2406. /**
  2407. * Copy the quaternion to an array
  2408. * @returns a new array populated with 4 elements from the quaternion coordinates
  2409. */
  2410. asArray(): number[];
  2411. /**
  2412. * Check if two quaternions are equals
  2413. * @param otherQuaternion defines the second operand
  2414. * @return true if the current quaternion and the given one coordinates are strictly equals
  2415. */
  2416. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2417. /**
  2418. * Clone the current quaternion
  2419. * @returns a new quaternion copied from the current one
  2420. */
  2421. clone(): Quaternion;
  2422. /**
  2423. * Copy a quaternion to the current one
  2424. * @param other defines the other quaternion
  2425. * @returns the updated current quaternion
  2426. */
  2427. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2428. /**
  2429. * Updates the current quaternion with the given float coordinates
  2430. * @param x defines the x coordinate
  2431. * @param y defines the y coordinate
  2432. * @param z defines the z coordinate
  2433. * @param w defines the w coordinate
  2434. * @returns the updated current quaternion
  2435. */
  2436. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2437. /**
  2438. * Updates the current quaternion from the given float coordinates
  2439. * @param x defines the x coordinate
  2440. * @param y defines the y coordinate
  2441. * @param z defines the z coordinate
  2442. * @param w defines the w coordinate
  2443. * @returns the updated current quaternion
  2444. */
  2445. set(x: number, y: number, z: number, w: number): Quaternion;
  2446. /**
  2447. * Adds two quaternions
  2448. * @param other defines the second operand
  2449. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2450. */
  2451. add(other: DeepImmutable<Quaternion>): Quaternion;
  2452. /**
  2453. * Add a quaternion to the current one
  2454. * @param other defines the quaternion to add
  2455. * @returns the current quaternion
  2456. */
  2457. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2458. /**
  2459. * Subtract two quaternions
  2460. * @param other defines the second operand
  2461. * @returns a new quaternion as the subtraction result of the given one from the current one
  2462. */
  2463. subtract(other: Quaternion): Quaternion;
  2464. /**
  2465. * Multiplies the current quaternion by a scale factor
  2466. * @param value defines the scale factor
  2467. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2468. */
  2469. scale(value: number): Quaternion;
  2470. /**
  2471. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2472. * @param scale defines the scale factor
  2473. * @param result defines the Quaternion object where to store the result
  2474. * @returns the unmodified current quaternion
  2475. */
  2476. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2477. /**
  2478. * Multiplies in place the current quaternion by a scale factor
  2479. * @param value defines the scale factor
  2480. * @returns the current modified quaternion
  2481. */
  2482. scaleInPlace(value: number): Quaternion;
  2483. /**
  2484. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2485. * @param scale defines the scale factor
  2486. * @param result defines the Quaternion object where to store the result
  2487. * @returns the unmodified current quaternion
  2488. */
  2489. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2490. /**
  2491. * Multiplies two quaternions
  2492. * @param q1 defines the second operand
  2493. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2494. */
  2495. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2496. /**
  2497. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2498. * @param q1 defines the second operand
  2499. * @param result defines the target quaternion
  2500. * @returns the current quaternion
  2501. */
  2502. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2503. /**
  2504. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @returns the currentupdated quaternion
  2507. */
  2508. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2509. /**
  2510. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2511. * @param ref defines the target quaternion
  2512. * @returns the current quaternion
  2513. */
  2514. conjugateToRef(ref: Quaternion): Quaternion;
  2515. /**
  2516. * Conjugates in place (1-q) the current quaternion
  2517. * @returns the current updated quaternion
  2518. */
  2519. conjugateInPlace(): Quaternion;
  2520. /**
  2521. * Conjugates in place (1-q) the current quaternion
  2522. * @returns a new quaternion
  2523. */
  2524. conjugate(): Quaternion;
  2525. /**
  2526. * Gets length of current quaternion
  2527. * @returns the quaternion length (float)
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Normalize in place the current quaternion
  2532. * @returns the current updated quaternion
  2533. */
  2534. normalize(): Quaternion;
  2535. /**
  2536. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2537. * @param order is a reserved parameter and is ignore for now
  2538. * @returns a new Vector3 containing the Euler angles
  2539. */
  2540. toEulerAngles(order?: string): Vector3;
  2541. /**
  2542. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2543. * @param result defines the vector which will be filled with the Euler angles
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns the current unchanged quaternion
  2546. */
  2547. toEulerAnglesToRef(result: Vector3): Quaternion;
  2548. /**
  2549. * Updates the given rotation matrix with the current quaternion values
  2550. * @param result defines the target matrix
  2551. * @returns the current unchanged quaternion
  2552. */
  2553. toRotationMatrix(result: Matrix): Quaternion;
  2554. /**
  2555. * Updates the current quaternion from the given rotation matrix values
  2556. * @param matrix defines the source matrix
  2557. * @returns the current updated quaternion
  2558. */
  2559. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2560. /**
  2561. * Creates a new quaternion from a rotation matrix
  2562. * @param matrix defines the source matrix
  2563. * @returns a new quaternion created from the given rotation matrix values
  2564. */
  2565. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2566. /**
  2567. * Updates the given quaternion with the given rotation matrix values
  2568. * @param matrix defines the source matrix
  2569. * @param result defines the target quaternion
  2570. */
  2571. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2572. /**
  2573. * Returns the dot product (float) between the quaternions "left" and "right"
  2574. * @param left defines the left operand
  2575. * @param right defines the right operand
  2576. * @returns the dot product
  2577. */
  2578. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2579. /**
  2580. * Checks if the two quaternions are close to each other
  2581. * @param quat0 defines the first quaternion to check
  2582. * @param quat1 defines the second quaternion to check
  2583. * @returns true if the two quaternions are close to each other
  2584. */
  2585. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2586. /**
  2587. * Creates an empty quaternion
  2588. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2589. */
  2590. static Zero(): Quaternion;
  2591. /**
  2592. * Inverse a given quaternion
  2593. * @param q defines the source quaternion
  2594. * @returns a new quaternion as the inverted current quaternion
  2595. */
  2596. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Inverse a given quaternion
  2599. * @param q defines the source quaternion
  2600. * @param result the quaternion the result will be stored in
  2601. * @returns the result quaternion
  2602. */
  2603. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2604. /**
  2605. * Creates an identity quaternion
  2606. * @returns the identity quaternion
  2607. */
  2608. static Identity(): Quaternion;
  2609. /**
  2610. * Gets a boolean indicating if the given quaternion is identity
  2611. * @param quaternion defines the quaternion to check
  2612. * @returns true if the quaternion is identity
  2613. */
  2614. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2615. /**
  2616. * Creates a quaternion from a rotation around an axis
  2617. * @param axis defines the axis to use
  2618. * @param angle defines the angle to use
  2619. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2620. */
  2621. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2622. /**
  2623. * Creates a rotation around an axis and stores it into the given quaternion
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @param result defines the target quaternion
  2627. * @returns the target quaternion
  2628. */
  2629. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2630. /**
  2631. * Creates a new quaternion from data stored into an array
  2632. * @param array defines the data source
  2633. * @param offset defines the offset in the source array where the data starts
  2634. * @returns a new quaternion
  2635. */
  2636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2637. /**
  2638. * Create a quaternion from Euler rotation angles
  2639. * @param x Pitch
  2640. * @param y Yaw
  2641. * @param z Roll
  2642. * @returns the new Quaternion
  2643. */
  2644. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2645. /**
  2646. * Updates a quaternion from Euler rotation angles
  2647. * @param x Pitch
  2648. * @param y Yaw
  2649. * @param z Roll
  2650. * @param result the quaternion to store the result
  2651. * @returns the updated quaternion
  2652. */
  2653. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2654. /**
  2655. * Create a quaternion from Euler rotation vector
  2656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2657. * @returns the new Quaternion
  2658. */
  2659. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2660. /**
  2661. * Updates a quaternion from Euler rotation vector
  2662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2663. * @param result the quaternion to store the result
  2664. * @returns the updated quaternion
  2665. */
  2666. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2667. /**
  2668. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2669. * @param yaw defines the rotation around Y axis
  2670. * @param pitch defines the rotation around X axis
  2671. * @param roll defines the rotation around Z axis
  2672. * @returns the new quaternion
  2673. */
  2674. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2675. /**
  2676. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2677. * @param yaw defines the rotation around Y axis
  2678. * @param pitch defines the rotation around X axis
  2679. * @param roll defines the rotation around Z axis
  2680. * @param result defines the target quaternion
  2681. */
  2682. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2683. /**
  2684. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2685. * @param alpha defines the rotation around first axis
  2686. * @param beta defines the rotation around second axis
  2687. * @param gamma defines the rotation around third axis
  2688. * @returns the new quaternion
  2689. */
  2690. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2691. /**
  2692. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2693. * @param alpha defines the rotation around first axis
  2694. * @param beta defines the rotation around second axis
  2695. * @param gamma defines the rotation around third axis
  2696. * @param result defines the target quaternion
  2697. */
  2698. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2699. /**
  2700. * 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)
  2701. * @param axis1 defines the first axis
  2702. * @param axis2 defines the second axis
  2703. * @param axis3 defines the third axis
  2704. * @returns the new quaternion
  2705. */
  2706. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2707. /**
  2708. * 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
  2709. * @param axis1 defines the first axis
  2710. * @param axis2 defines the second axis
  2711. * @param axis3 defines the third axis
  2712. * @param ref defines the target quaternion
  2713. */
  2714. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2715. /**
  2716. * Interpolates between two quaternions
  2717. * @param left defines first quaternion
  2718. * @param right defines second quaternion
  2719. * @param amount defines the gradient to use
  2720. * @returns the new interpolated quaternion
  2721. */
  2722. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2723. /**
  2724. * Interpolates between two quaternions and stores it into a target quaternion
  2725. * @param left defines first quaternion
  2726. * @param right defines second quaternion
  2727. * @param amount defines the gradient to use
  2728. * @param result defines the target quaternion
  2729. */
  2730. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2731. /**
  2732. * Interpolate between two quaternions using Hermite interpolation
  2733. * @param value1 defines first quaternion
  2734. * @param tangent1 defines the incoming tangent
  2735. * @param value2 defines second quaternion
  2736. * @param tangent2 defines the outgoing tangent
  2737. * @param amount defines the target quaternion
  2738. * @returns the new interpolated quaternion
  2739. */
  2740. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2741. }
  2742. /**
  2743. * Class used to store matrix data (4x4)
  2744. */
  2745. export class Matrix {
  2746. private static _updateFlagSeed;
  2747. private static _identityReadOnly;
  2748. private _isIdentity;
  2749. private _isIdentityDirty;
  2750. private _isIdentity3x2;
  2751. private _isIdentity3x2Dirty;
  2752. /**
  2753. * Gets the update flag of the matrix which is an unique number for the matrix.
  2754. * It will be incremented every time the matrix data change.
  2755. * You can use it to speed the comparison between two versions of the same matrix.
  2756. */
  2757. updateFlag: number;
  2758. private readonly _m;
  2759. /**
  2760. * Gets the internal data of the matrix
  2761. */
  2762. readonly m: DeepImmutable<Float32Array>;
  2763. /** @hidden */
  2764. _markAsUpdated(): void;
  2765. /** @hidden */
  2766. private _updateIdentityStatus;
  2767. /**
  2768. * Creates an empty matrix (filled with zeros)
  2769. */
  2770. constructor();
  2771. /**
  2772. * Check if the current matrix is identity
  2773. * @returns true is the matrix is the identity matrix
  2774. */
  2775. isIdentity(): boolean;
  2776. /**
  2777. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2778. * @returns true is the matrix is the identity matrix
  2779. */
  2780. isIdentityAs3x2(): boolean;
  2781. /**
  2782. * Gets the determinant of the matrix
  2783. * @returns the matrix determinant
  2784. */
  2785. determinant(): number;
  2786. /**
  2787. * Returns the matrix as a Float32Array
  2788. * @returns the matrix underlying array
  2789. */
  2790. toArray(): DeepImmutable<Float32Array>;
  2791. /**
  2792. * Returns the matrix as a Float32Array
  2793. * @returns the matrix underlying array.
  2794. */
  2795. asArray(): DeepImmutable<Float32Array>;
  2796. /**
  2797. * Inverts the current matrix in place
  2798. * @returns the current inverted matrix
  2799. */
  2800. invert(): Matrix;
  2801. /**
  2802. * Sets all the matrix elements to zero
  2803. * @returns the current matrix
  2804. */
  2805. reset(): Matrix;
  2806. /**
  2807. * Adds the current matrix with a second one
  2808. * @param other defines the matrix to add
  2809. * @returns a new matrix as the addition of the current matrix and the given one
  2810. */
  2811. add(other: DeepImmutable<Matrix>): Matrix;
  2812. /**
  2813. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2814. * @param other defines the matrix to add
  2815. * @param result defines the target matrix
  2816. * @returns the current matrix
  2817. */
  2818. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2819. /**
  2820. * Adds in place the given matrix to the current matrix
  2821. * @param other defines the second operand
  2822. * @returns the current updated matrix
  2823. */
  2824. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2825. /**
  2826. * Sets the given matrix to the current inverted Matrix
  2827. * @param other defines the target matrix
  2828. * @returns the unmodified current matrix
  2829. */
  2830. invertToRef(other: Matrix): Matrix;
  2831. /**
  2832. * add a value at the specified position in the current Matrix
  2833. * @param index the index of the value within the matrix. between 0 and 15.
  2834. * @param value the value to be added
  2835. * @returns the current updated matrix
  2836. */
  2837. addAtIndex(index: number, value: number): Matrix;
  2838. /**
  2839. * mutiply the specified position in the current Matrix by a value
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. multiplyAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * Inserts the translation vector (using 3 floats) in the current matrix
  2847. * @param x defines the 1st component of the translation
  2848. * @param y defines the 2nd component of the translation
  2849. * @param z defines the 3rd component of the translation
  2850. * @returns the current updated matrix
  2851. */
  2852. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2853. /**
  2854. * Adds the translation vector (using 3 floats) in the current matrix
  2855. * @param x defines the 1st component of the translation
  2856. * @param y defines the 2nd component of the translation
  2857. * @param z defines the 3rd component of the translation
  2858. * @returns the current updated matrix
  2859. */
  2860. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2861. /**
  2862. * Inserts the translation vector in the current matrix
  2863. * @param vector3 defines the translation to insert
  2864. * @returns the current updated matrix
  2865. */
  2866. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2867. /**
  2868. * Gets the translation value of the current matrix
  2869. * @returns a new Vector3 as the extracted translation from the matrix
  2870. */
  2871. getTranslation(): Vector3;
  2872. /**
  2873. * Fill a Vector3 with the extracted translation from the matrix
  2874. * @param result defines the Vector3 where to store the translation
  2875. * @returns the current matrix
  2876. */
  2877. getTranslationToRef(result: Vector3): Matrix;
  2878. /**
  2879. * Remove rotation and scaling part from the matrix
  2880. * @returns the updated matrix
  2881. */
  2882. removeRotationAndScaling(): Matrix;
  2883. /**
  2884. * Multiply two matrices
  2885. * @param other defines the second operand
  2886. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2887. */
  2888. multiply(other: DeepImmutable<Matrix>): Matrix;
  2889. /**
  2890. * Copy the current matrix from the given one
  2891. * @param other defines the source matrix
  2892. * @returns the current updated matrix
  2893. */
  2894. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2895. /**
  2896. * Populates the given array from the starting index with the current matrix values
  2897. * @param array defines the target array
  2898. * @param offset defines the offset in the target array where to start storing values
  2899. * @returns the current matrix
  2900. */
  2901. copyToArray(array: Float32Array, offset?: number): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2904. * @param other defines the second operand
  2905. * @param result defines the matrix where to store the multiplication
  2906. * @returns the current matrix
  2907. */
  2908. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the array where to store the multiplication
  2913. * @param offset defines the offset in the target array where to start storing values
  2914. * @returns the current matrix
  2915. */
  2916. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2917. /**
  2918. * Check equality between this matrix and a second one
  2919. * @param value defines the second matrix to compare
  2920. * @returns true is the current matrix and the given one values are strictly equal
  2921. */
  2922. equals(value: DeepImmutable<Matrix>): boolean;
  2923. /**
  2924. * Clone the current matrix
  2925. * @returns a new matrix from the current matrix
  2926. */
  2927. clone(): Matrix;
  2928. /**
  2929. * Returns the name of the current matrix class
  2930. * @returns the string "Matrix"
  2931. */
  2932. getClassName(): string;
  2933. /**
  2934. * Gets the hash code of the current matrix
  2935. * @returns the hash code
  2936. */
  2937. getHashCode(): number;
  2938. /**
  2939. * Decomposes the current Matrix into a translation, rotation and scaling components
  2940. * @param scale defines the scale vector3 given as a reference to update
  2941. * @param rotation defines the rotation quaternion given as a reference to update
  2942. * @param translation defines the translation vector3 given as a reference to update
  2943. * @returns true if operation was successful
  2944. */
  2945. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2946. /**
  2947. * Gets specific row of the matrix
  2948. * @param index defines the number of the row to get
  2949. * @returns the index-th row of the current matrix as a new Vector4
  2950. */
  2951. getRow(index: number): Nullable<Vector4>;
  2952. /**
  2953. * Sets the index-th row of the current matrix to the vector4 values
  2954. * @param index defines the number of the row to set
  2955. * @param row defines the target vector4
  2956. * @returns the updated current matrix
  2957. */
  2958. setRow(index: number, row: Vector4): Matrix;
  2959. /**
  2960. * Compute the transpose of the matrix
  2961. * @returns the new transposed matrix
  2962. */
  2963. transpose(): Matrix;
  2964. /**
  2965. * Compute the transpose of the matrix and store it in a given matrix
  2966. * @param result defines the target matrix
  2967. * @returns the current matrix
  2968. */
  2969. transposeToRef(result: Matrix): Matrix;
  2970. /**
  2971. * Sets the index-th row of the current matrix with the given 4 x float values
  2972. * @param index defines the row index
  2973. * @param x defines the x component to set
  2974. * @param y defines the y component to set
  2975. * @param z defines the z component to set
  2976. * @param w defines the w component to set
  2977. * @returns the updated current matrix
  2978. */
  2979. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2980. /**
  2981. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2982. * @param scale defines the scale factor
  2983. * @returns a new matrix
  2984. */
  2985. scale(scale: number): Matrix;
  2986. /**
  2987. * Scale the current matrix values by a factor to a given result matrix
  2988. * @param scale defines the scale factor
  2989. * @param result defines the matrix to store the result
  2990. * @returns the current matrix
  2991. */
  2992. scaleToRef(scale: number, result: Matrix): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor and add the result to a given matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the Matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3002. * @param ref matrix to store the result
  3003. */
  3004. toNormalMatrix(ref: Matrix): void;
  3005. /**
  3006. * Gets only rotation part of the current matrix
  3007. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3008. */
  3009. getRotationMatrix(): Matrix;
  3010. /**
  3011. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3012. * @param result defines the target matrix to store data to
  3013. * @returns the current matrix
  3014. */
  3015. getRotationMatrixToRef(result: Matrix): Matrix;
  3016. /**
  3017. * Toggles model matrix from being right handed to left handed in place and vice versa
  3018. */
  3019. toggleModelMatrixHandInPlace(): void;
  3020. /**
  3021. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3022. */
  3023. toggleProjectionMatrixHandInPlace(): void;
  3024. /**
  3025. * Creates a matrix from an array
  3026. * @param array defines the source array
  3027. * @param offset defines an offset in the source array
  3028. * @returns a new Matrix set from the starting index of the given array
  3029. */
  3030. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3031. /**
  3032. * Copy the content of an array into a given matrix
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @param result defines the target matrix
  3036. */
  3037. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3038. /**
  3039. * Stores an array into a matrix after having multiplied each component by a given factor
  3040. * @param array defines the source array
  3041. * @param offset defines the offset in the source array
  3042. * @param scale defines the scaling factor
  3043. * @param result defines the target matrix
  3044. */
  3045. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3046. /**
  3047. * Gets an identity matrix that must not be updated
  3048. */
  3049. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3050. /**
  3051. * Stores a list of values (16) inside a given matrix
  3052. * @param initialM11 defines 1st value of 1st row
  3053. * @param initialM12 defines 2nd value of 1st row
  3054. * @param initialM13 defines 3rd value of 1st row
  3055. * @param initialM14 defines 4th value of 1st row
  3056. * @param initialM21 defines 1st value of 2nd row
  3057. * @param initialM22 defines 2nd value of 2nd row
  3058. * @param initialM23 defines 3rd value of 2nd row
  3059. * @param initialM24 defines 4th value of 2nd row
  3060. * @param initialM31 defines 1st value of 3rd row
  3061. * @param initialM32 defines 2nd value of 3rd row
  3062. * @param initialM33 defines 3rd value of 3rd row
  3063. * @param initialM34 defines 4th value of 3rd row
  3064. * @param initialM41 defines 1st value of 4th row
  3065. * @param initialM42 defines 2nd value of 4th row
  3066. * @param initialM43 defines 3rd value of 4th row
  3067. * @param initialM44 defines 4th value of 4th row
  3068. * @param result defines the target matrix
  3069. */
  3070. 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;
  3071. /**
  3072. * Creates new matrix from a list of values (16)
  3073. * @param initialM11 defines 1st value of 1st row
  3074. * @param initialM12 defines 2nd value of 1st row
  3075. * @param initialM13 defines 3rd value of 1st row
  3076. * @param initialM14 defines 4th value of 1st row
  3077. * @param initialM21 defines 1st value of 2nd row
  3078. * @param initialM22 defines 2nd value of 2nd row
  3079. * @param initialM23 defines 3rd value of 2nd row
  3080. * @param initialM24 defines 4th value of 2nd row
  3081. * @param initialM31 defines 1st value of 3rd row
  3082. * @param initialM32 defines 2nd value of 3rd row
  3083. * @param initialM33 defines 3rd value of 3rd row
  3084. * @param initialM34 defines 4th value of 3rd row
  3085. * @param initialM41 defines 1st value of 4th row
  3086. * @param initialM42 defines 2nd value of 4th row
  3087. * @param initialM43 defines 3rd value of 4th row
  3088. * @param initialM44 defines 4th value of 4th row
  3089. * @returns the new matrix
  3090. */
  3091. 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;
  3092. /**
  3093. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3094. * @param scale defines the scale vector3
  3095. * @param rotation defines the rotation quaternion
  3096. * @param translation defines the translation vector3
  3097. * @returns a new matrix
  3098. */
  3099. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3100. /**
  3101. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3102. * @param scale defines the scale vector3
  3103. * @param rotation defines the rotation quaternion
  3104. * @param translation defines the translation vector3
  3105. * @param result defines the target matrix
  3106. */
  3107. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3108. /**
  3109. * Creates a new identity matrix
  3110. * @returns a new identity matrix
  3111. */
  3112. static Identity(): Matrix;
  3113. /**
  3114. * Creates a new identity matrix and stores the result in a given matrix
  3115. * @param result defines the target matrix
  3116. */
  3117. static IdentityToRef(result: Matrix): void;
  3118. /**
  3119. * Creates a new zero matrix
  3120. * @returns a new zero matrix
  3121. */
  3122. static Zero(): Matrix;
  3123. /**
  3124. * Creates a new rotation matrix for "angle" radians around the X axis
  3125. * @param angle defines the angle (in radians) to use
  3126. * @return the new matrix
  3127. */
  3128. static RotationX(angle: number): Matrix;
  3129. /**
  3130. * Creates a new matrix as the invert of a given matrix
  3131. * @param source defines the source matrix
  3132. * @returns the new matrix
  3133. */
  3134. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3135. /**
  3136. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3137. * @param angle defines the angle (in radians) to use
  3138. * @param result defines the target matrix
  3139. */
  3140. static RotationXToRef(angle: number, result: Matrix): void;
  3141. /**
  3142. * Creates a new rotation matrix for "angle" radians around the Y axis
  3143. * @param angle defines the angle (in radians) to use
  3144. * @return the new matrix
  3145. */
  3146. static RotationY(angle: number): Matrix;
  3147. /**
  3148. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3149. * @param angle defines the angle (in radians) to use
  3150. * @param result defines the target matrix
  3151. */
  3152. static RotationYToRef(angle: number, result: Matrix): void;
  3153. /**
  3154. * Creates a new rotation matrix for "angle" radians around the Z axis
  3155. * @param angle defines the angle (in radians) to use
  3156. * @return the new matrix
  3157. */
  3158. static RotationZ(angle: number): Matrix;
  3159. /**
  3160. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3161. * @param angle defines the angle (in radians) to use
  3162. * @param result defines the target matrix
  3163. */
  3164. static RotationZToRef(angle: number, result: Matrix): void;
  3165. /**
  3166. * Creates a new rotation matrix for "angle" radians around the given axis
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle (in radians) to use
  3169. * @return the new matrix
  3170. */
  3171. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @param result defines the target matrix
  3177. */
  3178. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3179. /**
  3180. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3181. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3182. * @param from defines the vector to align
  3183. * @param to defines the vector to align to
  3184. * @param result defines the target matrix
  3185. */
  3186. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3187. /**
  3188. * Creates a rotation matrix
  3189. * @param yaw defines the yaw angle in radians (Y axis)
  3190. * @param pitch defines the pitch angle in radians (X axis)
  3191. * @param roll defines the roll angle in radians (X axis)
  3192. * @returns the new rotation matrix
  3193. */
  3194. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3195. /**
  3196. * Creates a rotation matrix and stores it in a given matrix
  3197. * @param yaw defines the yaw angle in radians (Y axis)
  3198. * @param pitch defines the pitch angle in radians (X axis)
  3199. * @param roll defines the roll angle in radians (X axis)
  3200. * @param result defines the target matrix
  3201. */
  3202. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3203. /**
  3204. * Creates a scaling matrix
  3205. * @param x defines the scale factor on X axis
  3206. * @param y defines the scale factor on Y axis
  3207. * @param z defines the scale factor on Z axis
  3208. * @returns the new matrix
  3209. */
  3210. static Scaling(x: number, y: number, z: number): Matrix;
  3211. /**
  3212. * Creates a scaling matrix and stores it in a given matrix
  3213. * @param x defines the scale factor on X axis
  3214. * @param y defines the scale factor on Y axis
  3215. * @param z defines the scale factor on Z axis
  3216. * @param result defines the target matrix
  3217. */
  3218. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3219. /**
  3220. * Creates a translation matrix
  3221. * @param x defines the translation on X axis
  3222. * @param y defines the translation on Y axis
  3223. * @param z defines the translationon Z axis
  3224. * @returns the new matrix
  3225. */
  3226. static Translation(x: number, y: number, z: number): Matrix;
  3227. /**
  3228. * Creates a translation matrix and stores it in a given matrix
  3229. * @param x defines the translation on X axis
  3230. * @param y defines the translation on Y axis
  3231. * @param z defines the translationon Z axis
  3232. * @param result defines the target matrix
  3233. */
  3234. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3235. /**
  3236. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3237. * @param startValue defines the start value
  3238. * @param endValue defines the end value
  3239. * @param gradient defines the gradient factor
  3240. * @returns the new matrix
  3241. */
  3242. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3243. /**
  3244. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3245. * @param startValue defines the start value
  3246. * @param endValue defines the end value
  3247. * @param gradient defines the gradient factor
  3248. * @param result defines the Matrix object where to store data
  3249. */
  3250. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3251. /**
  3252. * Builds a new matrix whose values are computed by:
  3253. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3254. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3255. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3256. * @param startValue defines the first matrix
  3257. * @param endValue defines the second matrix
  3258. * @param gradient defines the gradient between the two matrices
  3259. * @returns the new matrix
  3260. */
  3261. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3262. /**
  3263. * Update a matrix to values which are computed by:
  3264. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3265. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3266. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3267. * @param startValue defines the first matrix
  3268. * @param endValue defines the second matrix
  3269. * @param gradient defines the gradient between the two matrices
  3270. * @param result defines the target matrix
  3271. */
  3272. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3273. /**
  3274. * 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"
  3275. * This function works in left handed mode
  3276. * @param eye defines the final position of the entity
  3277. * @param target defines where the entity should look at
  3278. * @param up defines the up vector for the entity
  3279. * @returns the new matrix
  3280. */
  3281. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3282. /**
  3283. * 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".
  3284. * This function works in left handed mode
  3285. * @param eye defines the final position of the entity
  3286. * @param target defines where the entity should look at
  3287. * @param up defines the up vector for the entity
  3288. * @param result defines the target matrix
  3289. */
  3290. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3291. /**
  3292. * 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"
  3293. * This function works in right handed mode
  3294. * @param eye defines the final position of the entity
  3295. * @param target defines where the entity should look at
  3296. * @param up defines the up vector for the entity
  3297. * @returns the new matrix
  3298. */
  3299. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3300. /**
  3301. * 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".
  3302. * This function works in right handed mode
  3303. * @param eye defines the final position of the entity
  3304. * @param target defines where the entity should look at
  3305. * @param up defines the up vector for the entity
  3306. * @param result defines the target matrix
  3307. */
  3308. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3309. /**
  3310. * Create a left-handed orthographic projection matrix
  3311. * @param width defines the viewport width
  3312. * @param height defines the viewport height
  3313. * @param znear defines the near clip plane
  3314. * @param zfar defines the far clip plane
  3315. * @returns a new matrix as a left-handed orthographic projection matrix
  3316. */
  3317. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3318. /**
  3319. * Store a left-handed orthographic projection to a given matrix
  3320. * @param width defines the viewport width
  3321. * @param height defines the viewport height
  3322. * @param znear defines the near clip plane
  3323. * @param zfar defines the far clip plane
  3324. * @param result defines the target matrix
  3325. */
  3326. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3327. /**
  3328. * Create a left-handed orthographic projection matrix
  3329. * @param left defines the viewport left coordinate
  3330. * @param right defines the viewport right coordinate
  3331. * @param bottom defines the viewport bottom coordinate
  3332. * @param top defines the viewport top coordinate
  3333. * @param znear defines the near clip plane
  3334. * @param zfar defines the far clip plane
  3335. * @returns a new matrix as a left-handed orthographic projection matrix
  3336. */
  3337. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3338. /**
  3339. * Stores a left-handed orthographic projection into a given matrix
  3340. * @param left defines the viewport left coordinate
  3341. * @param right defines the viewport right coordinate
  3342. * @param bottom defines the viewport bottom coordinate
  3343. * @param top defines the viewport top coordinate
  3344. * @param znear defines the near clip plane
  3345. * @param zfar defines the far clip plane
  3346. * @param result defines the target matrix
  3347. */
  3348. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3349. /**
  3350. * Creates a right-handed orthographic projection matrix
  3351. * @param left defines the viewport left coordinate
  3352. * @param right defines the viewport right coordinate
  3353. * @param bottom defines the viewport bottom coordinate
  3354. * @param top defines the viewport top coordinate
  3355. * @param znear defines the near clip plane
  3356. * @param zfar defines the far clip plane
  3357. * @returns a new matrix as a right-handed orthographic projection matrix
  3358. */
  3359. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3360. /**
  3361. * Stores a right-handed orthographic projection into a given matrix
  3362. * @param left defines the viewport left coordinate
  3363. * @param right defines the viewport right coordinate
  3364. * @param bottom defines the viewport bottom coordinate
  3365. * @param top defines the viewport top coordinate
  3366. * @param znear defines the near clip plane
  3367. * @param zfar defines the far clip plane
  3368. * @param result defines the target matrix
  3369. */
  3370. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3371. /**
  3372. * Creates a left-handed perspective projection matrix
  3373. * @param width defines the viewport width
  3374. * @param height defines the viewport height
  3375. * @param znear defines the near clip plane
  3376. * @param zfar defines the far clip plane
  3377. * @returns a new matrix as a left-handed perspective projection matrix
  3378. */
  3379. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3380. /**
  3381. * Creates a left-handed perspective projection matrix
  3382. * @param fov defines the horizontal field of view
  3383. * @param aspect defines the aspect ratio
  3384. * @param znear defines the near clip plane
  3385. * @param zfar defines the far clip plane
  3386. * @returns a new matrix as a left-handed perspective projection matrix
  3387. */
  3388. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3389. /**
  3390. * Stores a left-handed perspective projection into a given matrix
  3391. * @param fov defines the horizontal field of view
  3392. * @param aspect defines the aspect ratio
  3393. * @param znear defines the near clip plane
  3394. * @param zfar defines the far clip plane
  3395. * @param result defines the target matrix
  3396. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3397. */
  3398. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3399. /**
  3400. * Creates a right-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 right-handed perspective projection matrix
  3406. */
  3407. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a right-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 PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3418. /**
  3419. * Stores a perspective projection for WebVR info a given matrix
  3420. * @param fov defines the field of view
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @param result defines the target matrix
  3424. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3425. */
  3426. static PerspectiveFovWebVRToRef(fov: {
  3427. upDegrees: number;
  3428. downDegrees: number;
  3429. leftDegrees: number;
  3430. rightDegrees: number;
  3431. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3432. /**
  3433. * Computes a complete transformation matrix
  3434. * @param viewport defines the viewport to use
  3435. * @param world defines the world matrix
  3436. * @param view defines the view matrix
  3437. * @param projection defines the projection matrix
  3438. * @param zmin defines the near clip plane
  3439. * @param zmax defines the far clip plane
  3440. * @returns the transformation matrix
  3441. */
  3442. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3443. /**
  3444. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3445. * @param matrix defines the matrix to use
  3446. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3447. */
  3448. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3449. /**
  3450. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3451. * @param matrix defines the matrix to use
  3452. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3453. */
  3454. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3455. /**
  3456. * Compute the transpose of a given matrix
  3457. * @param matrix defines the matrix to transpose
  3458. * @returns the new matrix
  3459. */
  3460. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3461. /**
  3462. * Compute the transpose of a matrix and store it in a target matrix
  3463. * @param matrix defines the matrix to transpose
  3464. * @param result defines the target matrix
  3465. */
  3466. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3467. /**
  3468. * Computes a reflection matrix from a plane
  3469. * @param plane defines the reflection plane
  3470. * @returns a new matrix
  3471. */
  3472. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3473. /**
  3474. * Computes a reflection matrix from a plane
  3475. * @param plane defines the reflection plane
  3476. * @param result defines the target matrix
  3477. */
  3478. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3479. /**
  3480. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3481. * @param xaxis defines the value of the 1st axis
  3482. * @param yaxis defines the value of the 2nd axis
  3483. * @param zaxis defines the value of the 3rd axis
  3484. * @param result defines the target matrix
  3485. */
  3486. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3487. /**
  3488. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3489. * @param quat defines the quaternion to use
  3490. * @param result defines the target matrix
  3491. */
  3492. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3493. }
  3494. /**
  3495. * @hidden
  3496. */
  3497. export class TmpVectors {
  3498. static Vector2: Vector2[];
  3499. static Vector3: Vector3[];
  3500. static Vector4: Vector4[];
  3501. static Quaternion: Quaternion[];
  3502. static Matrix: Matrix[];
  3503. }
  3504. }
  3505. declare module BABYLON {
  3506. /**
  3507. * Class used to hold a RBG color
  3508. */
  3509. export class Color3 {
  3510. /**
  3511. * Defines the red component (between 0 and 1, default is 0)
  3512. */
  3513. r: number;
  3514. /**
  3515. * Defines the green component (between 0 and 1, default is 0)
  3516. */
  3517. g: number;
  3518. /**
  3519. * Defines the blue component (between 0 and 1, default is 0)
  3520. */
  3521. b: number;
  3522. /**
  3523. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3524. * @param r defines the red component (between 0 and 1, default is 0)
  3525. * @param g defines the green component (between 0 and 1, default is 0)
  3526. * @param b defines the blue component (between 0 and 1, default is 0)
  3527. */
  3528. constructor(
  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 string with the Color3 current values
  3543. * @returns the string representation of the Color3 object
  3544. */
  3545. toString(): string;
  3546. /**
  3547. * Returns the string "Color3"
  3548. * @returns "Color3"
  3549. */
  3550. getClassName(): string;
  3551. /**
  3552. * Compute the Color3 hash code
  3553. * @returns an unique number that can be used to hash Color3 objects
  3554. */
  3555. getHashCode(): number;
  3556. /**
  3557. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3558. * @param array defines the array where to store the r,g,b components
  3559. * @param index defines an optional index in the target array to define where to start storing values
  3560. * @returns the current Color3 object
  3561. */
  3562. toArray(array: FloatArray, index?: number): Color3;
  3563. /**
  3564. * Returns a new Color4 object from the current Color3 and the given alpha
  3565. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3566. * @returns a new Color4 object
  3567. */
  3568. toColor4(alpha?: number): Color4;
  3569. /**
  3570. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3571. * @returns the new array
  3572. */
  3573. asArray(): number[];
  3574. /**
  3575. * Returns the luminance value
  3576. * @returns a float value
  3577. */
  3578. toLuminance(): number;
  3579. /**
  3580. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3581. * @param otherColor defines the second operand
  3582. * @returns the new Color3 object
  3583. */
  3584. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3585. /**
  3586. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3587. * @param otherColor defines the second operand
  3588. * @param result defines the Color3 object where to store the result
  3589. * @returns the current Color3
  3590. */
  3591. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3592. /**
  3593. * Determines equality between Color3 objects
  3594. * @param otherColor defines the second operand
  3595. * @returns true if the rgb values are equal to the given ones
  3596. */
  3597. equals(otherColor: DeepImmutable<Color3>): boolean;
  3598. /**
  3599. * Determines equality between the current Color3 object and a set of r,b,g values
  3600. * @param r defines the red component to check
  3601. * @param g defines the green component to check
  3602. * @param b defines the blue component to check
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equalsFloats(r: number, g: number, b: number): boolean;
  3606. /**
  3607. * Multiplies in place each rgb value by scale
  3608. * @param scale defines the scaling factor
  3609. * @returns the updated Color3
  3610. */
  3611. scale(scale: number): Color3;
  3612. /**
  3613. * Multiplies the rgb values by scale and stores the result into "result"
  3614. * @param scale defines the scaling factor
  3615. * @param result defines the Color3 object where to store the result
  3616. * @returns the unmodified current Color3
  3617. */
  3618. scaleToRef(scale: number, result: Color3): Color3;
  3619. /**
  3620. * Scale the current Color3 values by a factor and add the result to a given Color3
  3621. * @param scale defines the scale factor
  3622. * @param result defines color to store the result into
  3623. * @returns the unmodified current Color3
  3624. */
  3625. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3626. /**
  3627. * Clamps the rgb values by the min and max values and stores the result into "result"
  3628. * @param min defines minimum clamping value (default is 0)
  3629. * @param max defines maximum clamping value (default is 1)
  3630. * @param result defines color to store the result into
  3631. * @returns the original Color3
  3632. */
  3633. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3634. /**
  3635. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3636. * @param otherColor defines the second operand
  3637. * @returns the new Color3
  3638. */
  3639. add(otherColor: DeepImmutable<Color3>): Color3;
  3640. /**
  3641. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3642. * @param otherColor defines the second operand
  3643. * @param result defines Color3 object to store the result into
  3644. * @returns the unmodified current Color3
  3645. */
  3646. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3647. /**
  3648. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3649. * @param otherColor defines the second operand
  3650. * @returns the new Color3
  3651. */
  3652. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3653. /**
  3654. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3655. * @param otherColor defines the second operand
  3656. * @param result defines Color3 object to store the result into
  3657. * @returns the unmodified current Color3
  3658. */
  3659. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3660. /**
  3661. * Copy the current object
  3662. * @returns a new Color3 copied the current one
  3663. */
  3664. clone(): Color3;
  3665. /**
  3666. * Copies the rgb values from the source in the current Color3
  3667. * @param source defines the source Color3 object
  3668. * @returns the updated Color3 object
  3669. */
  3670. copyFrom(source: DeepImmutable<Color3>): Color3;
  3671. /**
  3672. * Updates the Color3 rgb values from the given floats
  3673. * @param r defines the red component to read from
  3674. * @param g defines the green component to read from
  3675. * @param b defines the blue component to read from
  3676. * @returns the current Color3 object
  3677. */
  3678. copyFromFloats(r: number, g: number, b: number): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. set(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Compute the Color3 hexadecimal code as a string
  3689. * @returns a string containing the hexadecimal representation of the Color3 object
  3690. */
  3691. toHexString(): string;
  3692. /**
  3693. * Computes a new Color3 converted from the current one to linear space
  3694. * @returns a new Color3 object
  3695. */
  3696. toLinearSpace(): Color3;
  3697. /**
  3698. * Converts current color in rgb space to HSV values
  3699. * @returns a new color3 representing the HSV values
  3700. */
  3701. toHSV(): Color3;
  3702. /**
  3703. * Converts current color in rgb space to HSV values
  3704. * @param result defines the Color3 where to store the HSV values
  3705. */
  3706. toHSVToRef(result: Color3): void;
  3707. /**
  3708. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3709. * @param convertedColor defines the Color3 object where to store the linear space version
  3710. * @returns the unmodified Color3
  3711. */
  3712. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3713. /**
  3714. * Computes a new Color3 converted from the current one to gamma space
  3715. * @returns a new Color3 object
  3716. */
  3717. toGammaSpace(): Color3;
  3718. /**
  3719. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3720. * @param convertedColor defines the Color3 object where to store the gamma space version
  3721. * @returns the unmodified Color3
  3722. */
  3723. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3724. private static _BlackReadOnly;
  3725. /**
  3726. * Convert Hue, saturation and value to a Color3 (RGB)
  3727. * @param hue defines the hue
  3728. * @param saturation defines the saturation
  3729. * @param value defines the value
  3730. * @param result defines the Color3 where to store the RGB values
  3731. */
  3732. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3733. /**
  3734. * Creates a new Color3 from the string containing valid hexadecimal values
  3735. * @param hex defines a string containing valid hexadecimal values
  3736. * @returns a new Color3 object
  3737. */
  3738. static FromHexString(hex: string): Color3;
  3739. /**
  3740. * Creates a new Color3 from the starting index of the given array
  3741. * @param array defines the source array
  3742. * @param offset defines an offset in the source array
  3743. * @returns a new Color3 object
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3746. /**
  3747. * Creates a new Color3 from integer values (< 256)
  3748. * @param r defines the red component to read from (value between 0 and 255)
  3749. * @param g defines the green component to read from (value between 0 and 255)
  3750. * @param b defines the blue component to read from (value between 0 and 255)
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromInts(r: number, g: number, b: number): Color3;
  3754. /**
  3755. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3756. * @param start defines the start Color3 value
  3757. * @param end defines the end Color3 value
  3758. * @param amount defines the gradient value between start and end
  3759. * @returns a new Color3 object
  3760. */
  3761. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param left defines the start value
  3765. * @param right defines the end value
  3766. * @param amount defines the gradient factor
  3767. * @param result defines the Color3 object where to store the result
  3768. */
  3769. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3770. /**
  3771. * Returns a Color3 value containing a red color
  3772. * @returns a new Color3 object
  3773. */
  3774. static Red(): Color3;
  3775. /**
  3776. * Returns a Color3 value containing a green color
  3777. * @returns a new Color3 object
  3778. */
  3779. static Green(): Color3;
  3780. /**
  3781. * Returns a Color3 value containing a blue color
  3782. * @returns a new Color3 object
  3783. */
  3784. static Blue(): Color3;
  3785. /**
  3786. * Returns a Color3 value containing a black color
  3787. * @returns a new Color3 object
  3788. */
  3789. static Black(): Color3;
  3790. /**
  3791. * Gets a Color3 value containing a black color that must not be updated
  3792. */
  3793. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3794. /**
  3795. * Returns a Color3 value containing a white color
  3796. * @returns a new Color3 object
  3797. */
  3798. static White(): Color3;
  3799. /**
  3800. * Returns a Color3 value containing a purple color
  3801. * @returns a new Color3 object
  3802. */
  3803. static Purple(): Color3;
  3804. /**
  3805. * Returns a Color3 value containing a magenta color
  3806. * @returns a new Color3 object
  3807. */
  3808. static Magenta(): Color3;
  3809. /**
  3810. * Returns a Color3 value containing a yellow color
  3811. * @returns a new Color3 object
  3812. */
  3813. static Yellow(): Color3;
  3814. /**
  3815. * Returns a Color3 value containing a gray color
  3816. * @returns a new Color3 object
  3817. */
  3818. static Gray(): Color3;
  3819. /**
  3820. * Returns a Color3 value containing a teal color
  3821. * @returns a new Color3 object
  3822. */
  3823. static Teal(): Color3;
  3824. /**
  3825. * Returns a Color3 value containing a random color
  3826. * @returns a new Color3 object
  3827. */
  3828. static Random(): Color3;
  3829. }
  3830. /**
  3831. * Class used to hold a RBGA color
  3832. */
  3833. export class Color4 {
  3834. /**
  3835. * Defines the red component (between 0 and 1, default is 0)
  3836. */
  3837. r: number;
  3838. /**
  3839. * Defines the green component (between 0 and 1, default is 0)
  3840. */
  3841. g: number;
  3842. /**
  3843. * Defines the blue component (between 0 and 1, default is 0)
  3844. */
  3845. b: number;
  3846. /**
  3847. * Defines the alpha component (between 0 and 1, default is 1)
  3848. */
  3849. a: number;
  3850. /**
  3851. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3852. * @param r defines the red component (between 0 and 1, default is 0)
  3853. * @param g defines the green component (between 0 and 1, default is 0)
  3854. * @param b defines the blue component (between 0 and 1, default is 0)
  3855. * @param a defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. constructor(
  3858. /**
  3859. * Defines the red component (between 0 and 1, default is 0)
  3860. */
  3861. r?: number,
  3862. /**
  3863. * Defines the green component (between 0 and 1, default is 0)
  3864. */
  3865. g?: number,
  3866. /**
  3867. * Defines the blue component (between 0 and 1, default is 0)
  3868. */
  3869. b?: number,
  3870. /**
  3871. * Defines the alpha component (between 0 and 1, default is 1)
  3872. */
  3873. a?: number);
  3874. /**
  3875. * Adds in place the given Color4 values to the current Color4 object
  3876. * @param right defines the second operand
  3877. * @returns the current updated Color4 object
  3878. */
  3879. addInPlace(right: DeepImmutable<Color4>): Color4;
  3880. /**
  3881. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3882. * @returns the new array
  3883. */
  3884. asArray(): number[];
  3885. /**
  3886. * Stores from the starting index in the given array the Color4 successive values
  3887. * @param array defines the array where to store the r,g,b components
  3888. * @param index defines an optional index in the target array to define where to start storing values
  3889. * @returns the current Color4 object
  3890. */
  3891. toArray(array: number[], index?: number): Color4;
  3892. /**
  3893. * Determines equality between Color4 objects
  3894. * @param otherColor defines the second operand
  3895. * @returns true if the rgba values are equal to the given ones
  3896. */
  3897. equals(otherColor: DeepImmutable<Color4>): boolean;
  3898. /**
  3899. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3900. * @param right defines the second operand
  3901. * @returns a new Color4 object
  3902. */
  3903. add(right: DeepImmutable<Color4>): Color4;
  3904. /**
  3905. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3906. * @param right defines the second operand
  3907. * @returns a new Color4 object
  3908. */
  3909. subtract(right: DeepImmutable<Color4>): Color4;
  3910. /**
  3911. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3912. * @param right defines the second operand
  3913. * @param result defines the Color4 object where to store the result
  3914. * @returns the current Color4 object
  3915. */
  3916. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3917. /**
  3918. * Creates a new Color4 with the current Color4 values multiplied by scale
  3919. * @param scale defines the scaling factor to apply
  3920. * @returns a new Color4 object
  3921. */
  3922. scale(scale: number): Color4;
  3923. /**
  3924. * Multiplies the current Color4 values by scale and stores the result in "result"
  3925. * @param scale defines the scaling factor to apply
  3926. * @param result defines the Color4 object where to store the result
  3927. * @returns the current unmodified Color4
  3928. */
  3929. scaleToRef(scale: number, result: Color4): Color4;
  3930. /**
  3931. * Scale the current Color4 values by a factor and add the result to a given Color4
  3932. * @param scale defines the scale factor
  3933. * @param result defines the Color4 object where to store the result
  3934. * @returns the unmodified current Color4
  3935. */
  3936. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3937. /**
  3938. * Clamps the rgb values by the min and max values and stores the result into "result"
  3939. * @param min defines minimum clamping value (default is 0)
  3940. * @param max defines maximum clamping value (default is 1)
  3941. * @param result defines color to store the result into.
  3942. * @returns the cuurent Color4
  3943. */
  3944. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3945. /**
  3946. * Multipy an Color4 value by another and return a new Color4 object
  3947. * @param color defines the Color4 value to multiply by
  3948. * @returns a new Color4 object
  3949. */
  3950. multiply(color: Color4): Color4;
  3951. /**
  3952. * Multipy a Color4 value by another and push the result in a reference value
  3953. * @param color defines the Color4 value to multiply by
  3954. * @param result defines the Color4 to fill the result in
  3955. * @returns the result Color4
  3956. */
  3957. multiplyToRef(color: Color4, result: Color4): Color4;
  3958. /**
  3959. * Creates a string with the Color4 current values
  3960. * @returns the string representation of the Color4 object
  3961. */
  3962. toString(): string;
  3963. /**
  3964. * Returns the string "Color4"
  3965. * @returns "Color4"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Compute the Color4 hash code
  3970. * @returns an unique number that can be used to hash Color4 objects
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Creates a new Color4 copied from the current one
  3975. * @returns a new Color4 object
  3976. */
  3977. clone(): Color4;
  3978. /**
  3979. * Copies the given Color4 values into the current one
  3980. * @param source defines the source Color4 object
  3981. * @returns the current updated Color4 object
  3982. */
  3983. copyFrom(source: Color4): Color4;
  3984. /**
  3985. * Copies the given float values into the current one
  3986. * @param r defines the red component to read from
  3987. * @param g defines the green component to read from
  3988. * @param b defines the blue component to read from
  3989. * @param a defines the alpha component to read from
  3990. * @returns the current updated Color4 object
  3991. */
  3992. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  3993. /**
  3994. * Copies the given float values into the current one
  3995. * @param r defines the red component to read from
  3996. * @param g defines the green component to read from
  3997. * @param b defines the blue component to read from
  3998. * @param a defines the alpha component to read from
  3999. * @returns the current updated Color4 object
  4000. */
  4001. set(r: number, g: number, b: number, a: number): Color4;
  4002. /**
  4003. * Compute the Color4 hexadecimal code as a string
  4004. * @returns a string containing the hexadecimal representation of the Color4 object
  4005. */
  4006. toHexString(): string;
  4007. /**
  4008. * Computes a new Color4 converted from the current one to linear space
  4009. * @returns a new Color4 object
  4010. */
  4011. toLinearSpace(): Color4;
  4012. /**
  4013. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4014. * @param convertedColor defines the Color4 object where to store the linear space version
  4015. * @returns the unmodified Color4
  4016. */
  4017. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4018. /**
  4019. * Computes a new Color4 converted from the current one to gamma space
  4020. * @returns a new Color4 object
  4021. */
  4022. toGammaSpace(): Color4;
  4023. /**
  4024. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4025. * @param convertedColor defines the Color4 object where to store the gamma space version
  4026. * @returns the unmodified Color4
  4027. */
  4028. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4029. /**
  4030. * Creates a new Color4 from the string containing valid hexadecimal values
  4031. * @param hex defines a string containing valid hexadecimal values
  4032. * @returns a new Color4 object
  4033. */
  4034. static FromHexString(hex: string): Color4;
  4035. /**
  4036. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4037. * @param left defines the start value
  4038. * @param right defines the end value
  4039. * @param amount defines the gradient factor
  4040. * @returns a new Color4 object
  4041. */
  4042. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4043. /**
  4044. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @param result defines the Color4 object where to store data
  4049. */
  4050. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4051. /**
  4052. * Creates a new Color4 from a Color3 and an alpha value
  4053. * @param color3 defines the source Color3 to read from
  4054. * @param alpha defines the alpha component (1.0 by default)
  4055. * @returns a new Color4 object
  4056. */
  4057. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4058. /**
  4059. * Creates a new Color4 from the starting index element of the given array
  4060. * @param array defines the source array to read from
  4061. * @param offset defines the offset in the source array
  4062. * @returns a new Color4 object
  4063. */
  4064. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4065. /**
  4066. * Creates a new Color3 from integer values (< 256)
  4067. * @param r defines the red component to read from (value between 0 and 255)
  4068. * @param g defines the green component to read from (value between 0 and 255)
  4069. * @param b defines the blue component to read from (value between 0 and 255)
  4070. * @param a defines the alpha component to read from (value between 0 and 255)
  4071. * @returns a new Color3 object
  4072. */
  4073. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4074. /**
  4075. * Check the content of a given array and convert it to an array containing RGBA data
  4076. * If the original array was already containing count * 4 values then it is returned directly
  4077. * @param colors defines the array to check
  4078. * @param count defines the number of RGBA data to expect
  4079. * @returns an array containing count * 4 values (RGBA)
  4080. */
  4081. static CheckColors4(colors: number[], count: number): number[];
  4082. }
  4083. /**
  4084. * @hidden
  4085. */
  4086. export class TmpColors {
  4087. static Color3: Color3[];
  4088. static Color4: Color4[];
  4089. }
  4090. }
  4091. declare module BABYLON {
  4092. /**
  4093. * Class representing spherical harmonics coefficients to the 3rd degree
  4094. */
  4095. export class SphericalHarmonics {
  4096. /**
  4097. * Defines whether or not the harmonics have been prescaled for rendering.
  4098. */
  4099. preScaled: boolean;
  4100. /**
  4101. * The l0,0 coefficients of the spherical harmonics
  4102. */
  4103. l00: Vector3;
  4104. /**
  4105. * The l1,-1 coefficients of the spherical harmonics
  4106. */
  4107. l1_1: Vector3;
  4108. /**
  4109. * The l1,0 coefficients of the spherical harmonics
  4110. */
  4111. l10: Vector3;
  4112. /**
  4113. * The l1,1 coefficients of the spherical harmonics
  4114. */
  4115. l11: Vector3;
  4116. /**
  4117. * The l2,-2 coefficients of the spherical harmonics
  4118. */
  4119. l2_2: Vector3;
  4120. /**
  4121. * The l2,-1 coefficients of the spherical harmonics
  4122. */
  4123. l2_1: Vector3;
  4124. /**
  4125. * The l2,0 coefficients of the spherical harmonics
  4126. */
  4127. l20: Vector3;
  4128. /**
  4129. * The l2,1 coefficients of the spherical harmonics
  4130. */
  4131. l21: Vector3;
  4132. /**
  4133. * The l2,2 coefficients of the spherical harmonics
  4134. */
  4135. l22: Vector3;
  4136. /**
  4137. * Adds a light to the spherical harmonics
  4138. * @param direction the direction of the light
  4139. * @param color the color of the light
  4140. * @param deltaSolidAngle the delta solid angle of the light
  4141. */
  4142. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4143. /**
  4144. * Scales the spherical harmonics by the given amount
  4145. * @param scale the amount to scale
  4146. */
  4147. scaleInPlace(scale: number): void;
  4148. /**
  4149. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4150. *
  4151. * ```
  4152. * E_lm = A_l * L_lm
  4153. * ```
  4154. *
  4155. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4156. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4157. * the scaling factors are given in equation 9.
  4158. */
  4159. convertIncidentRadianceToIrradiance(): void;
  4160. /**
  4161. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4162. *
  4163. * ```
  4164. * L = (1/pi) * E * rho
  4165. * ```
  4166. *
  4167. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4168. */
  4169. convertIrradianceToLambertianRadiance(): void;
  4170. /**
  4171. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4172. * required operations at run time.
  4173. *
  4174. * This is simply done by scaling back the SH with Ylm constants parameter.
  4175. * The trigonometric part being applied by the shader at run time.
  4176. */
  4177. preScaleForRendering(): void;
  4178. /**
  4179. * Constructs a spherical harmonics from an array.
  4180. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4181. * @returns the spherical harmonics
  4182. */
  4183. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4184. /**
  4185. * Gets the spherical harmonics from polynomial
  4186. * @param polynomial the spherical polynomial
  4187. * @returns the spherical harmonics
  4188. */
  4189. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4190. }
  4191. /**
  4192. * Class representing spherical polynomial coefficients to the 3rd degree
  4193. */
  4194. export class SphericalPolynomial {
  4195. private _harmonics;
  4196. /**
  4197. * The spherical harmonics used to create the polynomials.
  4198. */
  4199. readonly preScaledHarmonics: SphericalHarmonics;
  4200. /**
  4201. * The x coefficients of the spherical polynomial
  4202. */
  4203. x: Vector3;
  4204. /**
  4205. * The y coefficients of the spherical polynomial
  4206. */
  4207. y: Vector3;
  4208. /**
  4209. * The z coefficients of the spherical polynomial
  4210. */
  4211. z: Vector3;
  4212. /**
  4213. * The xx coefficients of the spherical polynomial
  4214. */
  4215. xx: Vector3;
  4216. /**
  4217. * The yy coefficients of the spherical polynomial
  4218. */
  4219. yy: Vector3;
  4220. /**
  4221. * The zz coefficients of the spherical polynomial
  4222. */
  4223. zz: Vector3;
  4224. /**
  4225. * The xy coefficients of the spherical polynomial
  4226. */
  4227. xy: Vector3;
  4228. /**
  4229. * The yz coefficients of the spherical polynomial
  4230. */
  4231. yz: Vector3;
  4232. /**
  4233. * The zx coefficients of the spherical polynomial
  4234. */
  4235. zx: Vector3;
  4236. /**
  4237. * Adds an ambient color to the spherical polynomial
  4238. * @param color the color to add
  4239. */
  4240. addAmbient(color: Color3): void;
  4241. /**
  4242. * Scales the spherical polynomial by the given amount
  4243. * @param scale the amount to scale
  4244. */
  4245. scaleInPlace(scale: number): void;
  4246. /**
  4247. * Gets the spherical polynomial from harmonics
  4248. * @param harmonics the spherical harmonics
  4249. * @returns the spherical polynomial
  4250. */
  4251. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4252. /**
  4253. * Constructs a spherical polynomial from an array.
  4254. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4255. * @returns the spherical polynomial
  4256. */
  4257. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4258. }
  4259. }
  4260. declare module BABYLON {
  4261. /**
  4262. * Define options used to create a render target texture
  4263. */
  4264. export class RenderTargetCreationOptions {
  4265. /**
  4266. * Specifies is mipmaps must be generated
  4267. */
  4268. generateMipMaps?: boolean;
  4269. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4270. generateDepthBuffer?: boolean;
  4271. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4272. generateStencilBuffer?: boolean;
  4273. /** Defines texture type (int by default) */
  4274. type?: number;
  4275. /** Defines sampling mode (trilinear by default) */
  4276. samplingMode?: number;
  4277. /** Defines format (RGBA by default) */
  4278. format?: number;
  4279. }
  4280. }
  4281. declare module BABYLON {
  4282. /**
  4283. * @hidden
  4284. **/
  4285. export class _TimeToken {
  4286. _startTimeQuery: Nullable<WebGLQuery>;
  4287. _endTimeQuery: Nullable<WebGLQuery>;
  4288. _timeElapsedQuery: Nullable<WebGLQuery>;
  4289. _timeElapsedQueryEnded: boolean;
  4290. }
  4291. }
  4292. declare module BABYLON {
  4293. /** Defines the cross module used constants to avoid circular dependncies */
  4294. export class Constants {
  4295. /** Defines that alpha blending is disabled */
  4296. static readonly ALPHA_DISABLE: number;
  4297. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4298. static readonly ALPHA_ADD: number;
  4299. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4300. static readonly ALPHA_COMBINE: number;
  4301. /** Defines that alpha blending to DEST - SRC * DEST */
  4302. static readonly ALPHA_SUBTRACT: number;
  4303. /** Defines that alpha blending to SRC * DEST */
  4304. static readonly ALPHA_MULTIPLY: number;
  4305. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4306. static readonly ALPHA_MAXIMIZED: number;
  4307. /** Defines that alpha blending to SRC + DEST */
  4308. static readonly ALPHA_ONEONE: number;
  4309. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4310. static readonly ALPHA_PREMULTIPLIED: number;
  4311. /**
  4312. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4313. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4314. */
  4315. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4316. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4317. static readonly ALPHA_INTERPOLATE: number;
  4318. /**
  4319. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4320. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4321. */
  4322. static readonly ALPHA_SCREENMODE: number;
  4323. /**
  4324. * Defines that alpha blending to SRC + DST
  4325. * Alpha will be set to SRC ALPHA + DST ALPHA
  4326. */
  4327. static readonly ALPHA_ONEONE_ONEONE: number;
  4328. /**
  4329. * Defines that alpha blending to SRC * DST ALPHA + DST
  4330. * Alpha will be set to 0
  4331. */
  4332. static readonly ALPHA_ALPHATOCOLOR: number;
  4333. /**
  4334. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4335. */
  4336. static readonly ALPHA_REVERSEONEMINUS: number;
  4337. /**
  4338. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4339. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4340. */
  4341. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4342. /**
  4343. * Defines that alpha blending to SRC + DST
  4344. * Alpha will be set to SRC ALPHA
  4345. */
  4346. static readonly ALPHA_ONEONE_ONEZERO: number;
  4347. /** Defines that alpha blending equation a SUM */
  4348. static readonly ALPHA_EQUATION_ADD: number;
  4349. /** Defines that alpha blending equation a SUBSTRACTION */
  4350. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4351. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4352. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4353. /** Defines that alpha blending equation a MAX operation */
  4354. static readonly ALPHA_EQUATION_MAX: number;
  4355. /** Defines that alpha blending equation a MIN operation */
  4356. static readonly ALPHA_EQUATION_MIN: number;
  4357. /**
  4358. * Defines that alpha blending equation a DARKEN operation:
  4359. * It takes the min of the src and sums the alpha channels.
  4360. */
  4361. static readonly ALPHA_EQUATION_DARKEN: number;
  4362. /** Defines that the ressource is not delayed*/
  4363. static readonly DELAYLOADSTATE_NONE: number;
  4364. /** Defines that the ressource was successfully delay loaded */
  4365. static readonly DELAYLOADSTATE_LOADED: number;
  4366. /** Defines that the ressource is currently delay loading */
  4367. static readonly DELAYLOADSTATE_LOADING: number;
  4368. /** Defines that the ressource is delayed and has not started loading */
  4369. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4370. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4371. static readonly NEVER: number;
  4372. /** 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 */
  4373. static readonly ALWAYS: number;
  4374. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4375. static readonly LESS: number;
  4376. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4377. static readonly EQUAL: number;
  4378. /** 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 */
  4379. static readonly LEQUAL: number;
  4380. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4381. static readonly GREATER: number;
  4382. /** 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 */
  4383. static readonly GEQUAL: number;
  4384. /** 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 */
  4385. static readonly NOTEQUAL: number;
  4386. /** Passed to stencilOperation to specify that stencil value must be kept */
  4387. static readonly KEEP: number;
  4388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4389. static readonly REPLACE: number;
  4390. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4391. static readonly INCR: number;
  4392. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4393. static readonly DECR: number;
  4394. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4395. static readonly INVERT: number;
  4396. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4397. static readonly INCR_WRAP: number;
  4398. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4399. static readonly DECR_WRAP: number;
  4400. /** Texture is not repeating outside of 0..1 UVs */
  4401. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4402. /** Texture is repeating outside of 0..1 UVs */
  4403. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4404. /** Texture is repeating and mirrored */
  4405. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4406. /** ALPHA */
  4407. static readonly TEXTUREFORMAT_ALPHA: number;
  4408. /** LUMINANCE */
  4409. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4410. /** LUMINANCE_ALPHA */
  4411. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4412. /** RGB */
  4413. static readonly TEXTUREFORMAT_RGB: number;
  4414. /** RGBA */
  4415. static readonly TEXTUREFORMAT_RGBA: number;
  4416. /** RED */
  4417. static readonly TEXTUREFORMAT_RED: number;
  4418. /** RED (2nd reference) */
  4419. static readonly TEXTUREFORMAT_R: number;
  4420. /** RG */
  4421. static readonly TEXTUREFORMAT_RG: number;
  4422. /** RED_INTEGER */
  4423. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4424. /** RED_INTEGER (2nd reference) */
  4425. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4426. /** RG_INTEGER */
  4427. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4428. /** RGB_INTEGER */
  4429. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4430. /** RGBA_INTEGER */
  4431. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4432. /** UNSIGNED_BYTE */
  4433. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4434. /** UNSIGNED_BYTE (2nd reference) */
  4435. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4436. /** FLOAT */
  4437. static readonly TEXTURETYPE_FLOAT: number;
  4438. /** HALF_FLOAT */
  4439. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4440. /** BYTE */
  4441. static readonly TEXTURETYPE_BYTE: number;
  4442. /** SHORT */
  4443. static readonly TEXTURETYPE_SHORT: number;
  4444. /** UNSIGNED_SHORT */
  4445. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4446. /** INT */
  4447. static readonly TEXTURETYPE_INT: number;
  4448. /** UNSIGNED_INT */
  4449. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4450. /** UNSIGNED_SHORT_4_4_4_4 */
  4451. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4452. /** UNSIGNED_SHORT_5_5_5_1 */
  4453. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4454. /** UNSIGNED_SHORT_5_6_5 */
  4455. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4456. /** UNSIGNED_INT_2_10_10_10_REV */
  4457. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4458. /** UNSIGNED_INT_24_8 */
  4459. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4460. /** UNSIGNED_INT_10F_11F_11F_REV */
  4461. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4462. /** UNSIGNED_INT_5_9_9_9_REV */
  4463. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4464. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4465. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4466. /** nearest is mag = nearest and min = nearest and mip = linear */
  4467. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4468. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4469. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4470. /** Trilinear is mag = linear and min = linear and mip = linear */
  4471. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4472. /** nearest is mag = nearest and min = nearest and mip = linear */
  4473. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4475. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4476. /** Trilinear is mag = linear and min = linear and mip = linear */
  4477. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4478. /** mag = nearest and min = nearest and mip = nearest */
  4479. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4480. /** mag = nearest and min = linear and mip = nearest */
  4481. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4482. /** mag = nearest and min = linear and mip = linear */
  4483. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4484. /** mag = nearest and min = linear and mip = none */
  4485. static readonly TEXTURE_NEAREST_LINEAR: number;
  4486. /** mag = nearest and min = nearest and mip = none */
  4487. static readonly TEXTURE_NEAREST_NEAREST: number;
  4488. /** mag = linear and min = nearest and mip = nearest */
  4489. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4490. /** mag = linear and min = nearest and mip = linear */
  4491. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4492. /** mag = linear and min = linear and mip = none */
  4493. static readonly TEXTURE_LINEAR_LINEAR: number;
  4494. /** mag = linear and min = nearest and mip = none */
  4495. static readonly TEXTURE_LINEAR_NEAREST: number;
  4496. /** Explicit coordinates mode */
  4497. static readonly TEXTURE_EXPLICIT_MODE: number;
  4498. /** Spherical coordinates mode */
  4499. static readonly TEXTURE_SPHERICAL_MODE: number;
  4500. /** Planar coordinates mode */
  4501. static readonly TEXTURE_PLANAR_MODE: number;
  4502. /** Cubic coordinates mode */
  4503. static readonly TEXTURE_CUBIC_MODE: number;
  4504. /** Projection coordinates mode */
  4505. static readonly TEXTURE_PROJECTION_MODE: number;
  4506. /** Skybox coordinates mode */
  4507. static readonly TEXTURE_SKYBOX_MODE: number;
  4508. /** Inverse Cubic coordinates mode */
  4509. static readonly TEXTURE_INVCUBIC_MODE: number;
  4510. /** Equirectangular coordinates mode */
  4511. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4512. /** Equirectangular Fixed coordinates mode */
  4513. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4514. /** Equirectangular Fixed Mirrored coordinates mode */
  4515. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4516. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4517. static readonly SCALEMODE_FLOOR: number;
  4518. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4519. static readonly SCALEMODE_NEAREST: number;
  4520. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4521. static readonly SCALEMODE_CEILING: number;
  4522. /**
  4523. * The dirty texture flag value
  4524. */
  4525. static readonly MATERIAL_TextureDirtyFlag: number;
  4526. /**
  4527. * The dirty light flag value
  4528. */
  4529. static readonly MATERIAL_LightDirtyFlag: number;
  4530. /**
  4531. * The dirty fresnel flag value
  4532. */
  4533. static readonly MATERIAL_FresnelDirtyFlag: number;
  4534. /**
  4535. * The dirty attribute flag value
  4536. */
  4537. static readonly MATERIAL_AttributesDirtyFlag: number;
  4538. /**
  4539. * The dirty misc flag value
  4540. */
  4541. static readonly MATERIAL_MiscDirtyFlag: number;
  4542. /**
  4543. * The all dirty flag value
  4544. */
  4545. static readonly MATERIAL_AllDirtyFlag: number;
  4546. /**
  4547. * Returns the triangle fill mode
  4548. */
  4549. static readonly MATERIAL_TriangleFillMode: number;
  4550. /**
  4551. * Returns the wireframe mode
  4552. */
  4553. static readonly MATERIAL_WireFrameFillMode: number;
  4554. /**
  4555. * Returns the point fill mode
  4556. */
  4557. static readonly MATERIAL_PointFillMode: number;
  4558. /**
  4559. * Returns the point list draw mode
  4560. */
  4561. static readonly MATERIAL_PointListDrawMode: number;
  4562. /**
  4563. * Returns the line list draw mode
  4564. */
  4565. static readonly MATERIAL_LineListDrawMode: number;
  4566. /**
  4567. * Returns the line loop draw mode
  4568. */
  4569. static readonly MATERIAL_LineLoopDrawMode: number;
  4570. /**
  4571. * Returns the line strip draw mode
  4572. */
  4573. static readonly MATERIAL_LineStripDrawMode: number;
  4574. /**
  4575. * Returns the triangle strip draw mode
  4576. */
  4577. static readonly MATERIAL_TriangleStripDrawMode: number;
  4578. /**
  4579. * Returns the triangle fan draw mode
  4580. */
  4581. static readonly MATERIAL_TriangleFanDrawMode: number;
  4582. /**
  4583. * Stores the clock-wise side orientation
  4584. */
  4585. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4586. /**
  4587. * Stores the counter clock-wise side orientation
  4588. */
  4589. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4590. /**
  4591. * Nothing
  4592. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4593. */
  4594. static readonly ACTION_NothingTrigger: number;
  4595. /**
  4596. * On pick
  4597. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4598. */
  4599. static readonly ACTION_OnPickTrigger: number;
  4600. /**
  4601. * On left pick
  4602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4603. */
  4604. static readonly ACTION_OnLeftPickTrigger: number;
  4605. /**
  4606. * On right pick
  4607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4608. */
  4609. static readonly ACTION_OnRightPickTrigger: number;
  4610. /**
  4611. * On center pick
  4612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4613. */
  4614. static readonly ACTION_OnCenterPickTrigger: number;
  4615. /**
  4616. * On pick down
  4617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4618. */
  4619. static readonly ACTION_OnPickDownTrigger: number;
  4620. /**
  4621. * On double pick
  4622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4623. */
  4624. static readonly ACTION_OnDoublePickTrigger: number;
  4625. /**
  4626. * On pick up
  4627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4628. */
  4629. static readonly ACTION_OnPickUpTrigger: number;
  4630. /**
  4631. * On pick out.
  4632. * This trigger will only be raised if you also declared a OnPickDown
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnPickOutTrigger: number;
  4636. /**
  4637. * On long press
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnLongPressTrigger: number;
  4641. /**
  4642. * On pointer over
  4643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4644. */
  4645. static readonly ACTION_OnPointerOverTrigger: number;
  4646. /**
  4647. * On pointer out
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4649. */
  4650. static readonly ACTION_OnPointerOutTrigger: number;
  4651. /**
  4652. * On every frame
  4653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4654. */
  4655. static readonly ACTION_OnEveryFrameTrigger: number;
  4656. /**
  4657. * On intersection enter
  4658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4659. */
  4660. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4661. /**
  4662. * On intersection exit
  4663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4664. */
  4665. static readonly ACTION_OnIntersectionExitTrigger: number;
  4666. /**
  4667. * On key down
  4668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4669. */
  4670. static readonly ACTION_OnKeyDownTrigger: number;
  4671. /**
  4672. * On key up
  4673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4674. */
  4675. static readonly ACTION_OnKeyUpTrigger: number;
  4676. /**
  4677. * Billboard mode will only apply to Y axis
  4678. */
  4679. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4680. /**
  4681. * Billboard mode will apply to all axes
  4682. */
  4683. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4684. /**
  4685. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4686. */
  4687. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4688. /**
  4689. * Gets or sets base Assets URL
  4690. */
  4691. static PARTICLES_BaseAssetsUrl: string;
  4692. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4693. * Test order :
  4694. * Is the bounding sphere outside the frustum ?
  4695. * If not, are the bounding box vertices outside the frustum ?
  4696. * It not, then the cullable object is in the frustum.
  4697. */
  4698. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4699. /** Culling strategy : Bounding Sphere Only.
  4700. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4701. * It's also less accurate than the standard because some not visible objects can still be selected.
  4702. * Test : is the bounding sphere outside the frustum ?
  4703. * If not, then the cullable object is in the frustum.
  4704. */
  4705. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4706. /** Culling strategy : Optimistic Inclusion.
  4707. * This in an inclusion test first, then the standard exclusion test.
  4708. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4709. * 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.
  4710. * Anyway, it's as accurate as the standard strategy.
  4711. * Test :
  4712. * Is the cullable object bounding sphere center in the frustum ?
  4713. * If not, apply the default culling strategy.
  4714. */
  4715. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4716. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4717. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4718. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4719. * 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.
  4720. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4721. * Test :
  4722. * Is the cullable object bounding sphere center in the frustum ?
  4723. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4724. */
  4725. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4726. /**
  4727. * No logging while loading
  4728. */
  4729. static readonly SCENELOADER_NO_LOGGING: number;
  4730. /**
  4731. * Minimal logging while loading
  4732. */
  4733. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4734. /**
  4735. * Summary logging while loading
  4736. */
  4737. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4738. /**
  4739. * Detailled logging while loading
  4740. */
  4741. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4742. }
  4743. }
  4744. declare module BABYLON {
  4745. /**
  4746. * This represents the required contract to create a new type of texture loader.
  4747. */
  4748. export interface IInternalTextureLoader {
  4749. /**
  4750. * Defines wether the loader supports cascade loading the different faces.
  4751. */
  4752. supportCascades: boolean;
  4753. /**
  4754. * This returns if the loader support the current file information.
  4755. * @param extension defines the file extension of the file being loaded
  4756. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4757. * @param fallback defines the fallback internal texture if any
  4758. * @param isBase64 defines whether the texture is encoded as a base64
  4759. * @param isBuffer defines whether the texture data are stored as a buffer
  4760. * @returns true if the loader can load the specified file
  4761. */
  4762. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4763. /**
  4764. * Transform the url before loading if required.
  4765. * @param rootUrl the url of the texture
  4766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4767. * @returns the transformed texture
  4768. */
  4769. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4770. /**
  4771. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4772. * @param rootUrl the url of the texture
  4773. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4774. * @returns the fallback texture
  4775. */
  4776. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4777. /**
  4778. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4779. * @param data contains the texture data
  4780. * @param texture defines the BabylonJS internal texture
  4781. * @param createPolynomials will be true if polynomials have been requested
  4782. * @param onLoad defines the callback to trigger once the texture is ready
  4783. * @param onError defines the callback to trigger in case of error
  4784. */
  4785. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4786. /**
  4787. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4788. * @param data contains the texture data
  4789. * @param texture defines the BabylonJS internal texture
  4790. * @param callback defines the method to call once ready to upload
  4791. */
  4792. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4793. }
  4794. }
  4795. declare module BABYLON {
  4796. /**
  4797. * Class used to store and describe the pipeline context associated with an effect
  4798. */
  4799. export interface IPipelineContext {
  4800. /**
  4801. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4802. */
  4803. isAsync: boolean;
  4804. /**
  4805. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4806. */
  4807. isReady: boolean;
  4808. /** @hidden */
  4809. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4810. }
  4811. }
  4812. declare module BABYLON {
  4813. /**
  4814. * Class used to store gfx data (like WebGLBuffer)
  4815. */
  4816. export class DataBuffer {
  4817. /**
  4818. * Gets or sets the number of objects referencing this buffer
  4819. */
  4820. references: number;
  4821. /** Gets or sets the size of the underlying buffer */
  4822. capacity: number;
  4823. /**
  4824. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4825. */
  4826. is32Bits: boolean;
  4827. /**
  4828. * Gets the underlying buffer
  4829. */
  4830. readonly underlyingResource: any;
  4831. }
  4832. }
  4833. declare module BABYLON {
  4834. /** @hidden */
  4835. export interface IShaderProcessor {
  4836. attributeProcessor?: (attribute: string) => string;
  4837. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4838. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4839. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4840. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4841. lineProcessor?: (line: string, isFragment: boolean) => string;
  4842. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4843. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4844. }
  4845. }
  4846. declare module BABYLON {
  4847. /** @hidden */
  4848. export interface ProcessingOptions {
  4849. defines: string[];
  4850. indexParameters: any;
  4851. isFragment: boolean;
  4852. shouldUseHighPrecisionShader: boolean;
  4853. supportsUniformBuffers: boolean;
  4854. shadersRepository: string;
  4855. includesShadersStore: {
  4856. [key: string]: string;
  4857. };
  4858. processor?: IShaderProcessor;
  4859. version: string;
  4860. platformName: string;
  4861. lookForClosingBracketForUniformBuffer?: boolean;
  4862. }
  4863. }
  4864. declare module BABYLON {
  4865. /**
  4866. * Helper to manipulate strings
  4867. */
  4868. export class StringTools {
  4869. /**
  4870. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4871. * @param str Source string
  4872. * @param suffix Suffix to search for in the source string
  4873. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4874. */
  4875. static EndsWith(str: string, suffix: string): boolean;
  4876. /**
  4877. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4878. * @param str Source string
  4879. * @param suffix Suffix to search for in the source string
  4880. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4881. */
  4882. static StartsWith(str: string, suffix: string): boolean;
  4883. }
  4884. }
  4885. declare module BABYLON {
  4886. /** @hidden */
  4887. export class ShaderCodeNode {
  4888. line: string;
  4889. children: ShaderCodeNode[];
  4890. additionalDefineKey?: string;
  4891. additionalDefineValue?: string;
  4892. isValid(preprocessors: {
  4893. [key: string]: string;
  4894. }): boolean;
  4895. process(preprocessors: {
  4896. [key: string]: string;
  4897. }, options: ProcessingOptions): string;
  4898. }
  4899. }
  4900. declare module BABYLON {
  4901. /** @hidden */
  4902. export class ShaderCodeCursor {
  4903. private _lines;
  4904. lineIndex: number;
  4905. readonly currentLine: string;
  4906. readonly canRead: boolean;
  4907. lines: string[];
  4908. }
  4909. }
  4910. declare module BABYLON {
  4911. /** @hidden */
  4912. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4913. process(preprocessors: {
  4914. [key: string]: string;
  4915. }, options: ProcessingOptions): string;
  4916. }
  4917. }
  4918. declare module BABYLON {
  4919. /** @hidden */
  4920. export class ShaderDefineExpression {
  4921. isTrue(preprocessors: {
  4922. [key: string]: string;
  4923. }): boolean;
  4924. }
  4925. }
  4926. declare module BABYLON {
  4927. /** @hidden */
  4928. export class ShaderCodeTestNode extends ShaderCodeNode {
  4929. testExpression: ShaderDefineExpression;
  4930. isValid(preprocessors: {
  4931. [key: string]: string;
  4932. }): boolean;
  4933. }
  4934. }
  4935. declare module BABYLON {
  4936. /** @hidden */
  4937. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4938. define: string;
  4939. not: boolean;
  4940. constructor(define: string, not?: boolean);
  4941. isTrue(preprocessors: {
  4942. [key: string]: string;
  4943. }): boolean;
  4944. }
  4945. }
  4946. declare module BABYLON {
  4947. /** @hidden */
  4948. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4949. leftOperand: ShaderDefineExpression;
  4950. rightOperand: ShaderDefineExpression;
  4951. isTrue(preprocessors: {
  4952. [key: string]: string;
  4953. }): boolean;
  4954. }
  4955. }
  4956. declare module BABYLON {
  4957. /** @hidden */
  4958. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4959. leftOperand: ShaderDefineExpression;
  4960. rightOperand: ShaderDefineExpression;
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module BABYLON {
  4967. /** @hidden */
  4968. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4969. define: string;
  4970. operand: string;
  4971. testValue: string;
  4972. constructor(define: string, operand: string, testValue: string);
  4973. isTrue(preprocessors: {
  4974. [key: string]: string;
  4975. }): boolean;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. /**
  4980. * @ignore
  4981. * Application error to support additional information when loading a file
  4982. */
  4983. export class LoadFileError extends Error {
  4984. /** defines the optional web request */
  4985. request?: WebRequest | undefined;
  4986. private static _setPrototypeOf;
  4987. /**
  4988. * Creates a new LoadFileError
  4989. * @param message defines the message of the error
  4990. * @param request defines the optional web request
  4991. */
  4992. constructor(message: string,
  4993. /** defines the optional web request */
  4994. request?: WebRequest | undefined);
  4995. }
  4996. }
  4997. declare module BABYLON {
  4998. /**
  4999. * Class used to enable access to offline support
  5000. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5001. */
  5002. export interface IOfflineProvider {
  5003. /**
  5004. * Gets a boolean indicating if scene must be saved in the database
  5005. */
  5006. enableSceneOffline: boolean;
  5007. /**
  5008. * Gets a boolean indicating if textures must be saved in the database
  5009. */
  5010. enableTexturesOffline: boolean;
  5011. /**
  5012. * Open the offline support and make it available
  5013. * @param successCallback defines the callback to call on success
  5014. * @param errorCallback defines the callback to call on error
  5015. */
  5016. open(successCallback: () => void, errorCallback: () => void): void;
  5017. /**
  5018. * Loads an image from the offline support
  5019. * @param url defines the url to load from
  5020. * @param image defines the target DOM image
  5021. */
  5022. loadImage(url: string, image: HTMLImageElement): void;
  5023. /**
  5024. * Loads a file from offline support
  5025. * @param url defines the URL to load from
  5026. * @param sceneLoaded defines a callback to call on success
  5027. * @param progressCallBack defines a callback to call when progress changed
  5028. * @param errorCallback defines a callback to call on error
  5029. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5030. */
  5031. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5032. }
  5033. }
  5034. declare module BABYLON {
  5035. /**
  5036. * Class used to help managing file picking and drag'n'drop
  5037. * File Storage
  5038. */
  5039. export class FilesInputStore {
  5040. /**
  5041. * List of files ready to be loaded
  5042. */
  5043. static FilesToLoad: {
  5044. [key: string]: File;
  5045. };
  5046. }
  5047. }
  5048. declare module BABYLON {
  5049. /**
  5050. * Class used to define a retry strategy when error happens while loading assets
  5051. */
  5052. export class RetryStrategy {
  5053. /**
  5054. * Function used to defines an exponential back off strategy
  5055. * @param maxRetries defines the maximum number of retries (3 by default)
  5056. * @param baseInterval defines the interval between retries
  5057. * @returns the strategy function to use
  5058. */
  5059. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5060. }
  5061. }
  5062. declare module BABYLON {
  5063. /**
  5064. * @hidden
  5065. */
  5066. export class FileTools {
  5067. /**
  5068. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5069. */
  5070. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5071. /**
  5072. * Gets or sets the base URL to use to load assets
  5073. */
  5074. static BaseUrl: string;
  5075. /**
  5076. * Default behaviour for cors in the application.
  5077. * It can be a string if the expected behavior is identical in the entire app.
  5078. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5079. */
  5080. static CorsBehavior: string | ((url: string | string[]) => string);
  5081. /**
  5082. * Gets or sets a function used to pre-process url before using them to load assets
  5083. */
  5084. static PreprocessUrl: (url: string) => string;
  5085. /**
  5086. * Removes unwanted characters from an url
  5087. * @param url defines the url to clean
  5088. * @returns the cleaned url
  5089. */
  5090. private static _CleanUrl;
  5091. /**
  5092. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5093. * @param url define the url we are trying
  5094. * @param element define the dom element where to configure the cors policy
  5095. */
  5096. static SetCorsBehavior(url: string | string[], element: {
  5097. crossOrigin: string | null;
  5098. }): void;
  5099. /**
  5100. * Loads an image as an HTMLImageElement.
  5101. * @param input url string, ArrayBuffer, or Blob to load
  5102. * @param onLoad callback called when the image successfully loads
  5103. * @param onError callback called when the image fails to load
  5104. * @param offlineProvider offline provider for caching
  5105. * @returns the HTMLImageElement of the loaded image
  5106. */
  5107. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5108. /**
  5109. * Loads a file
  5110. * @param fileToLoad defines the file to load
  5111. * @param callback defines the callback to call when data is loaded
  5112. * @param progressCallBack defines the callback to call during loading process
  5113. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5114. * @returns a file request object
  5115. */
  5116. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5117. /**
  5118. * Loads a file
  5119. * @param url url string, ArrayBuffer, or Blob to load
  5120. * @param onSuccess callback called when the file successfully loads
  5121. * @param onProgress callback called while file is loading (if the server supports this mode)
  5122. * @param offlineProvider defines the offline provider for caching
  5123. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5124. * @param onError callback called when the file fails to load
  5125. * @returns a file request object
  5126. */
  5127. 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;
  5128. /**
  5129. * Checks if the loaded document was accessed via `file:`-Protocol.
  5130. * @returns boolean
  5131. */
  5132. static IsFileURL(): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /** @hidden */
  5137. export class ShaderProcessor {
  5138. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5139. private static _ProcessPrecision;
  5140. private static _ExtractOperation;
  5141. private static _BuildSubExpression;
  5142. private static _BuildExpression;
  5143. private static _MoveCursorWithinIf;
  5144. private static _MoveCursor;
  5145. private static _EvaluatePreProcessors;
  5146. private static _PreparePreProcessors;
  5147. private static _ProcessShaderConversion;
  5148. private static _ProcessIncludes;
  5149. }
  5150. }
  5151. declare module BABYLON {
  5152. /**
  5153. * Class used to evalaute queries containing `and` and `or` operators
  5154. */
  5155. export class AndOrNotEvaluator {
  5156. /**
  5157. * Evaluate a query
  5158. * @param query defines the query to evaluate
  5159. * @param evaluateCallback defines the callback used to filter result
  5160. * @returns true if the query matches
  5161. */
  5162. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5163. private static _HandleParenthesisContent;
  5164. private static _SimplifyNegation;
  5165. }
  5166. }
  5167. declare module BABYLON {
  5168. /**
  5169. * Class used to store custom tags
  5170. */
  5171. export class Tags {
  5172. /**
  5173. * Adds support for tags on the given object
  5174. * @param obj defines the object to use
  5175. */
  5176. static EnableFor(obj: any): void;
  5177. /**
  5178. * Removes tags support
  5179. * @param obj defines the object to use
  5180. */
  5181. static DisableFor(obj: any): void;
  5182. /**
  5183. * Gets a boolean indicating if the given object has tags
  5184. * @param obj defines the object to use
  5185. * @returns a boolean
  5186. */
  5187. static HasTags(obj: any): boolean;
  5188. /**
  5189. * Gets the tags available on a given object
  5190. * @param obj defines the object to use
  5191. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5192. * @returns the tags
  5193. */
  5194. static GetTags(obj: any, asString?: boolean): any;
  5195. /**
  5196. * Adds tags to an object
  5197. * @param obj defines the object to use
  5198. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5199. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5200. */
  5201. static AddTagsTo(obj: any, tagsString: string): void;
  5202. /**
  5203. * @hidden
  5204. */
  5205. static _AddTagTo(obj: any, tag: string): void;
  5206. /**
  5207. * Removes specific tags from a specific object
  5208. * @param obj defines the object to use
  5209. * @param tagsString defines the tags to remove
  5210. */
  5211. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5212. /**
  5213. * @hidden
  5214. */
  5215. static _RemoveTagFrom(obj: any, tag: string): void;
  5216. /**
  5217. * Defines if tags hosted on an object match a given query
  5218. * @param obj defines the object to use
  5219. * @param tagsQuery defines the tag query
  5220. * @returns a boolean
  5221. */
  5222. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5223. }
  5224. }
  5225. declare module BABYLON {
  5226. /**
  5227. * Defines potential orientation for back face culling
  5228. */
  5229. export enum Orientation {
  5230. /**
  5231. * Clockwise
  5232. */
  5233. CW = 0,
  5234. /** Counter clockwise */
  5235. CCW = 1
  5236. }
  5237. /** Class used to represent a Bezier curve */
  5238. export class BezierCurve {
  5239. /**
  5240. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5241. * @param t defines the time
  5242. * @param x1 defines the left coordinate on X axis
  5243. * @param y1 defines the left coordinate on Y axis
  5244. * @param x2 defines the right coordinate on X axis
  5245. * @param y2 defines the right coordinate on Y axis
  5246. * @returns the interpolated value
  5247. */
  5248. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5249. }
  5250. /**
  5251. * Defines angle representation
  5252. */
  5253. export class Angle {
  5254. private _radians;
  5255. /**
  5256. * Creates an Angle object of "radians" radians (float).
  5257. * @param radians the angle in radians
  5258. */
  5259. constructor(radians: number);
  5260. /**
  5261. * Get value in degrees
  5262. * @returns the Angle value in degrees (float)
  5263. */
  5264. degrees(): number;
  5265. /**
  5266. * Get value in radians
  5267. * @returns the Angle value in radians (float)
  5268. */
  5269. radians(): number;
  5270. /**
  5271. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5272. * @param a defines first vector
  5273. * @param b defines second vector
  5274. * @returns a new Angle
  5275. */
  5276. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5277. /**
  5278. * Gets a new Angle object from the given float in radians
  5279. * @param radians defines the angle value in radians
  5280. * @returns a new Angle
  5281. */
  5282. static FromRadians(radians: number): Angle;
  5283. /**
  5284. * Gets a new Angle object from the given float in degrees
  5285. * @param degrees defines the angle value in degrees
  5286. * @returns a new Angle
  5287. */
  5288. static FromDegrees(degrees: number): Angle;
  5289. }
  5290. /**
  5291. * This represents an arc in a 2d space.
  5292. */
  5293. export class Arc2 {
  5294. /** Defines the start point of the arc */
  5295. startPoint: Vector2;
  5296. /** Defines the mid point of the arc */
  5297. midPoint: Vector2;
  5298. /** Defines the end point of the arc */
  5299. endPoint: Vector2;
  5300. /**
  5301. * Defines the center point of the arc.
  5302. */
  5303. centerPoint: Vector2;
  5304. /**
  5305. * Defines the radius of the arc.
  5306. */
  5307. radius: number;
  5308. /**
  5309. * Defines the angle of the arc (from mid point to end point).
  5310. */
  5311. angle: Angle;
  5312. /**
  5313. * Defines the start angle of the arc (from start point to middle point).
  5314. */
  5315. startAngle: Angle;
  5316. /**
  5317. * Defines the orientation of the arc (clock wise/counter clock wise).
  5318. */
  5319. orientation: Orientation;
  5320. /**
  5321. * Creates an Arc object from the three given points : start, middle and end.
  5322. * @param startPoint Defines the start point of the arc
  5323. * @param midPoint Defines the midlle point of the arc
  5324. * @param endPoint Defines the end point of the arc
  5325. */
  5326. constructor(
  5327. /** Defines the start point of the arc */
  5328. startPoint: Vector2,
  5329. /** Defines the mid point of the arc */
  5330. midPoint: Vector2,
  5331. /** Defines the end point of the arc */
  5332. endPoint: Vector2);
  5333. }
  5334. /**
  5335. * Represents a 2D path made up of multiple 2D points
  5336. */
  5337. export class Path2 {
  5338. private _points;
  5339. private _length;
  5340. /**
  5341. * If the path start and end point are the same
  5342. */
  5343. closed: boolean;
  5344. /**
  5345. * Creates a Path2 object from the starting 2D coordinates x and y.
  5346. * @param x the starting points x value
  5347. * @param y the starting points y value
  5348. */
  5349. constructor(x: number, y: number);
  5350. /**
  5351. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5352. * @param x the added points x value
  5353. * @param y the added points y value
  5354. * @returns the updated Path2.
  5355. */
  5356. addLineTo(x: number, y: number): Path2;
  5357. /**
  5358. * 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.
  5359. * @param midX middle point x value
  5360. * @param midY middle point y value
  5361. * @param endX end point x value
  5362. * @param endY end point y value
  5363. * @param numberOfSegments (default: 36)
  5364. * @returns the updated Path2.
  5365. */
  5366. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5367. /**
  5368. * Closes the Path2.
  5369. * @returns the Path2.
  5370. */
  5371. close(): Path2;
  5372. /**
  5373. * Gets the sum of the distance between each sequential point in the path
  5374. * @returns the Path2 total length (float).
  5375. */
  5376. length(): number;
  5377. /**
  5378. * Gets the points which construct the path
  5379. * @returns the Path2 internal array of points.
  5380. */
  5381. getPoints(): Vector2[];
  5382. /**
  5383. * Retreives the point at the distance aways from the starting point
  5384. * @param normalizedLengthPosition the length along the path to retreive the point from
  5385. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5386. */
  5387. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5388. /**
  5389. * Creates a new path starting from an x and y position
  5390. * @param x starting x value
  5391. * @param y starting y value
  5392. * @returns a new Path2 starting at the coordinates (x, y).
  5393. */
  5394. static StartingAt(x: number, y: number): Path2;
  5395. }
  5396. /**
  5397. * Represents a 3D path made up of multiple 3D points
  5398. */
  5399. export class Path3D {
  5400. /**
  5401. * an array of Vector3, the curve axis of the Path3D
  5402. */
  5403. path: Vector3[];
  5404. private _curve;
  5405. private _distances;
  5406. private _tangents;
  5407. private _normals;
  5408. private _binormals;
  5409. private _raw;
  5410. /**
  5411. * new Path3D(path, normal, raw)
  5412. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5413. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5414. * @param path an array of Vector3, the curve axis of the Path3D
  5415. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5416. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5417. */
  5418. constructor(
  5419. /**
  5420. * an array of Vector3, the curve axis of the Path3D
  5421. */
  5422. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5423. /**
  5424. * Returns the Path3D array of successive Vector3 designing its curve.
  5425. * @returns the Path3D array of successive Vector3 designing its curve.
  5426. */
  5427. getCurve(): Vector3[];
  5428. /**
  5429. * Returns an array populated with tangent vectors on each Path3D curve point.
  5430. * @returns an array populated with tangent vectors on each Path3D curve point.
  5431. */
  5432. getTangents(): Vector3[];
  5433. /**
  5434. * Returns an array populated with normal vectors on each Path3D curve point.
  5435. * @returns an array populated with normal vectors on each Path3D curve point.
  5436. */
  5437. getNormals(): Vector3[];
  5438. /**
  5439. * Returns an array populated with binormal vectors on each Path3D curve point.
  5440. * @returns an array populated with binormal vectors on each Path3D curve point.
  5441. */
  5442. getBinormals(): Vector3[];
  5443. /**
  5444. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5445. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5446. */
  5447. getDistances(): number[];
  5448. /**
  5449. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5450. * @param path path which all values are copied into the curves points
  5451. * @param firstNormal which should be projected onto the curve
  5452. * @returns the same object updated.
  5453. */
  5454. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5455. private _compute;
  5456. private _getFirstNonNullVector;
  5457. private _getLastNonNullVector;
  5458. private _normalVector;
  5459. }
  5460. /**
  5461. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5462. * A Curve3 is designed from a series of successive Vector3.
  5463. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5464. */
  5465. export class Curve3 {
  5466. private _points;
  5467. private _length;
  5468. /**
  5469. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5470. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5471. * @param v1 (Vector3) the control point
  5472. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5473. * @param nbPoints (integer) the wanted number of points in the curve
  5474. * @returns the created Curve3
  5475. */
  5476. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5477. /**
  5478. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5479. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5480. * @param v1 (Vector3) the first control point
  5481. * @param v2 (Vector3) the second control point
  5482. * @param v3 (Vector3) the end point of the Cubic Bezier
  5483. * @param nbPoints (integer) the wanted number of points in the curve
  5484. * @returns the created Curve3
  5485. */
  5486. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5487. /**
  5488. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5489. * @param p1 (Vector3) the origin point of the Hermite Spline
  5490. * @param t1 (Vector3) the tangent vector at the origin point
  5491. * @param p2 (Vector3) the end point of the Hermite Spline
  5492. * @param t2 (Vector3) the tangent vector at the end point
  5493. * @param nbPoints (integer) the wanted number of points in the curve
  5494. * @returns the created Curve3
  5495. */
  5496. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5497. /**
  5498. * Returns a Curve3 object along a CatmullRom Spline curve :
  5499. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5500. * @param nbPoints (integer) the wanted number of points between each curve control points
  5501. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5502. * @returns the created Curve3
  5503. */
  5504. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5505. /**
  5506. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5507. * A Curve3 is designed from a series of successive Vector3.
  5508. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5509. * @param points points which make up the curve
  5510. */
  5511. constructor(points: Vector3[]);
  5512. /**
  5513. * @returns the Curve3 stored array of successive Vector3
  5514. */
  5515. getPoints(): Vector3[];
  5516. /**
  5517. * @returns the computed length (float) of the curve.
  5518. */
  5519. length(): number;
  5520. /**
  5521. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5522. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5523. * curveA and curveB keep unchanged.
  5524. * @param curve the curve to continue from this curve
  5525. * @returns the newly constructed curve
  5526. */
  5527. continue(curve: DeepImmutable<Curve3>): Curve3;
  5528. private _computeLength;
  5529. }
  5530. }
  5531. declare module BABYLON {
  5532. /**
  5533. * This represents the main contract an easing function should follow.
  5534. * Easing functions are used throughout the animation system.
  5535. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5536. */
  5537. export interface IEasingFunction {
  5538. /**
  5539. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5540. * of the easing function.
  5541. * The link below provides some of the most common examples of easing functions.
  5542. * @see https://easings.net/
  5543. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5544. * @returns the corresponding value on the curve defined by the easing function
  5545. */
  5546. ease(gradient: number): number;
  5547. }
  5548. /**
  5549. * Base class used for every default easing function.
  5550. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5551. */
  5552. export class EasingFunction implements IEasingFunction {
  5553. /**
  5554. * Interpolation follows the mathematical formula associated with the easing function.
  5555. */
  5556. static readonly EASINGMODE_EASEIN: number;
  5557. /**
  5558. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5559. */
  5560. static readonly EASINGMODE_EASEOUT: number;
  5561. /**
  5562. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5563. */
  5564. static readonly EASINGMODE_EASEINOUT: number;
  5565. private _easingMode;
  5566. /**
  5567. * Sets the easing mode of the current function.
  5568. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5569. */
  5570. setEasingMode(easingMode: number): void;
  5571. /**
  5572. * Gets the current easing mode.
  5573. * @returns the easing mode
  5574. */
  5575. getEasingMode(): number;
  5576. /**
  5577. * @hidden
  5578. */
  5579. easeInCore(gradient: number): number;
  5580. /**
  5581. * Given an input gradient between 0 and 1, this returns the corresponding value
  5582. * of the easing function.
  5583. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5584. * @returns the corresponding value on the curve defined by the easing function
  5585. */
  5586. ease(gradient: number): number;
  5587. }
  5588. /**
  5589. * Easing function with a circle shape (see link below).
  5590. * @see https://easings.net/#easeInCirc
  5591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5592. */
  5593. export class CircleEase extends EasingFunction implements IEasingFunction {
  5594. /** @hidden */
  5595. easeInCore(gradient: number): number;
  5596. }
  5597. /**
  5598. * Easing function with a ease back shape (see link below).
  5599. * @see https://easings.net/#easeInBack
  5600. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5601. */
  5602. export class BackEase extends EasingFunction implements IEasingFunction {
  5603. /** Defines the amplitude of the function */
  5604. amplitude: number;
  5605. /**
  5606. * Instantiates a back ease easing
  5607. * @see https://easings.net/#easeInBack
  5608. * @param amplitude Defines the amplitude of the function
  5609. */
  5610. constructor(
  5611. /** Defines the amplitude of the function */
  5612. amplitude?: number);
  5613. /** @hidden */
  5614. easeInCore(gradient: number): number;
  5615. }
  5616. /**
  5617. * Easing function with a bouncing shape (see link below).
  5618. * @see https://easings.net/#easeInBounce
  5619. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5620. */
  5621. export class BounceEase extends EasingFunction implements IEasingFunction {
  5622. /** Defines the number of bounces */
  5623. bounces: number;
  5624. /** Defines the amplitude of the bounce */
  5625. bounciness: number;
  5626. /**
  5627. * Instantiates a bounce easing
  5628. * @see https://easings.net/#easeInBounce
  5629. * @param bounces Defines the number of bounces
  5630. * @param bounciness Defines the amplitude of the bounce
  5631. */
  5632. constructor(
  5633. /** Defines the number of bounces */
  5634. bounces?: number,
  5635. /** Defines the amplitude of the bounce */
  5636. bounciness?: number);
  5637. /** @hidden */
  5638. easeInCore(gradient: number): number;
  5639. }
  5640. /**
  5641. * Easing function with a power of 3 shape (see link below).
  5642. * @see https://easings.net/#easeInCubic
  5643. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5644. */
  5645. export class CubicEase extends EasingFunction implements IEasingFunction {
  5646. /** @hidden */
  5647. easeInCore(gradient: number): number;
  5648. }
  5649. /**
  5650. * Easing function with an elastic shape (see link below).
  5651. * @see https://easings.net/#easeInElastic
  5652. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5653. */
  5654. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5655. /** Defines the number of oscillations*/
  5656. oscillations: number;
  5657. /** Defines the amplitude of the oscillations*/
  5658. springiness: number;
  5659. /**
  5660. * Instantiates an elastic easing function
  5661. * @see https://easings.net/#easeInElastic
  5662. * @param oscillations Defines the number of oscillations
  5663. * @param springiness Defines the amplitude of the oscillations
  5664. */
  5665. constructor(
  5666. /** Defines the number of oscillations*/
  5667. oscillations?: number,
  5668. /** Defines the amplitude of the oscillations*/
  5669. springiness?: number);
  5670. /** @hidden */
  5671. easeInCore(gradient: number): number;
  5672. }
  5673. /**
  5674. * Easing function with an exponential shape (see link below).
  5675. * @see https://easings.net/#easeInExpo
  5676. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5677. */
  5678. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5679. /** Defines the exponent of the function */
  5680. exponent: number;
  5681. /**
  5682. * Instantiates an exponential easing function
  5683. * @see https://easings.net/#easeInExpo
  5684. * @param exponent Defines the exponent of the function
  5685. */
  5686. constructor(
  5687. /** Defines the exponent of the function */
  5688. exponent?: number);
  5689. /** @hidden */
  5690. easeInCore(gradient: number): number;
  5691. }
  5692. /**
  5693. * Easing function with a power shape (see link below).
  5694. * @see https://easings.net/#easeInQuad
  5695. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5696. */
  5697. export class PowerEase extends EasingFunction implements IEasingFunction {
  5698. /** Defines the power of the function */
  5699. power: number;
  5700. /**
  5701. * Instantiates an power base easing function
  5702. * @see https://easings.net/#easeInQuad
  5703. * @param power Defines the power of the function
  5704. */
  5705. constructor(
  5706. /** Defines the power of the function */
  5707. power?: number);
  5708. /** @hidden */
  5709. easeInCore(gradient: number): number;
  5710. }
  5711. /**
  5712. * Easing function with a power of 2 shape (see link below).
  5713. * @see https://easings.net/#easeInQuad
  5714. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5715. */
  5716. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5717. /** @hidden */
  5718. easeInCore(gradient: number): number;
  5719. }
  5720. /**
  5721. * Easing function with a power of 4 shape (see link below).
  5722. * @see https://easings.net/#easeInQuart
  5723. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5724. */
  5725. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5726. /** @hidden */
  5727. easeInCore(gradient: number): number;
  5728. }
  5729. /**
  5730. * Easing function with a power of 5 shape (see link below).
  5731. * @see https://easings.net/#easeInQuint
  5732. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5733. */
  5734. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5735. /** @hidden */
  5736. easeInCore(gradient: number): number;
  5737. }
  5738. /**
  5739. * Easing function with a sin shape (see link below).
  5740. * @see https://easings.net/#easeInSine
  5741. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5742. */
  5743. export class SineEase extends EasingFunction implements IEasingFunction {
  5744. /** @hidden */
  5745. easeInCore(gradient: number): number;
  5746. }
  5747. /**
  5748. * Easing function with a bezier shape (see link below).
  5749. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5751. */
  5752. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5753. /** Defines the x component of the start tangent in the bezier curve */
  5754. x1: number;
  5755. /** Defines the y component of the start tangent in the bezier curve */
  5756. y1: number;
  5757. /** Defines the x component of the end tangent in the bezier curve */
  5758. x2: number;
  5759. /** Defines the y component of the end tangent in the bezier curve */
  5760. y2: number;
  5761. /**
  5762. * Instantiates a bezier function
  5763. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5764. * @param x1 Defines the x component of the start tangent in the bezier curve
  5765. * @param y1 Defines the y component of the start tangent in the bezier curve
  5766. * @param x2 Defines the x component of the end tangent in the bezier curve
  5767. * @param y2 Defines the y component of the end tangent in the bezier curve
  5768. */
  5769. constructor(
  5770. /** Defines the x component of the start tangent in the bezier curve */
  5771. x1?: number,
  5772. /** Defines the y component of the start tangent in the bezier curve */
  5773. y1?: number,
  5774. /** Defines the x component of the end tangent in the bezier curve */
  5775. x2?: number,
  5776. /** Defines the y component of the end tangent in the bezier curve */
  5777. y2?: number);
  5778. /** @hidden */
  5779. easeInCore(gradient: number): number;
  5780. }
  5781. }
  5782. declare module BABYLON {
  5783. /**
  5784. * Defines an interface which represents an animation key frame
  5785. */
  5786. export interface IAnimationKey {
  5787. /**
  5788. * Frame of the key frame
  5789. */
  5790. frame: number;
  5791. /**
  5792. * Value at the specifies key frame
  5793. */
  5794. value: any;
  5795. /**
  5796. * The input tangent for the cubic hermite spline
  5797. */
  5798. inTangent?: any;
  5799. /**
  5800. * The output tangent for the cubic hermite spline
  5801. */
  5802. outTangent?: any;
  5803. /**
  5804. * The animation interpolation type
  5805. */
  5806. interpolation?: AnimationKeyInterpolation;
  5807. }
  5808. /**
  5809. * Enum for the animation key frame interpolation type
  5810. */
  5811. export enum AnimationKeyInterpolation {
  5812. /**
  5813. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5814. */
  5815. STEP = 1
  5816. }
  5817. }
  5818. declare module BABYLON {
  5819. /**
  5820. * Represents the range of an animation
  5821. */
  5822. export class AnimationRange {
  5823. /**The name of the animation range**/
  5824. name: string;
  5825. /**The starting frame of the animation */
  5826. from: number;
  5827. /**The ending frame of the animation*/
  5828. to: number;
  5829. /**
  5830. * Initializes the range of an animation
  5831. * @param name The name of the animation range
  5832. * @param from The starting frame of the animation
  5833. * @param to The ending frame of the animation
  5834. */
  5835. constructor(
  5836. /**The name of the animation range**/
  5837. name: string,
  5838. /**The starting frame of the animation */
  5839. from: number,
  5840. /**The ending frame of the animation*/
  5841. to: number);
  5842. /**
  5843. * Makes a copy of the animation range
  5844. * @returns A copy of the animation range
  5845. */
  5846. clone(): AnimationRange;
  5847. }
  5848. }
  5849. declare module BABYLON {
  5850. /**
  5851. * Composed of a frame, and an action function
  5852. */
  5853. export class AnimationEvent {
  5854. /** The frame for which the event is triggered **/
  5855. frame: number;
  5856. /** The event to perform when triggered **/
  5857. action: (currentFrame: number) => void;
  5858. /** Specifies if the event should be triggered only once**/
  5859. onlyOnce?: boolean | undefined;
  5860. /**
  5861. * Specifies if the animation event is done
  5862. */
  5863. isDone: boolean;
  5864. /**
  5865. * Initializes the animation event
  5866. * @param frame The frame for which the event is triggered
  5867. * @param action The event to perform when triggered
  5868. * @param onlyOnce Specifies if the event should be triggered only once
  5869. */
  5870. constructor(
  5871. /** The frame for which the event is triggered **/
  5872. frame: number,
  5873. /** The event to perform when triggered **/
  5874. action: (currentFrame: number) => void,
  5875. /** Specifies if the event should be triggered only once**/
  5876. onlyOnce?: boolean | undefined);
  5877. /** @hidden */
  5878. _clone(): AnimationEvent;
  5879. }
  5880. }
  5881. declare module BABYLON {
  5882. /**
  5883. * Interface used to define a behavior
  5884. */
  5885. export interface Behavior<T> {
  5886. /** gets or sets behavior's name */
  5887. name: string;
  5888. /**
  5889. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5890. */
  5891. init(): void;
  5892. /**
  5893. * Called when the behavior is attached to a target
  5894. * @param target defines the target where the behavior is attached to
  5895. */
  5896. attach(target: T): void;
  5897. /**
  5898. * Called when the behavior is detached from its target
  5899. */
  5900. detach(): void;
  5901. }
  5902. /**
  5903. * Interface implemented by classes supporting behaviors
  5904. */
  5905. export interface IBehaviorAware<T> {
  5906. /**
  5907. * Attach a behavior
  5908. * @param behavior defines the behavior to attach
  5909. * @returns the current host
  5910. */
  5911. addBehavior(behavior: Behavior<T>): T;
  5912. /**
  5913. * Remove a behavior from the current object
  5914. * @param behavior defines the behavior to detach
  5915. * @returns the current host
  5916. */
  5917. removeBehavior(behavior: Behavior<T>): T;
  5918. /**
  5919. * Gets a behavior using its name to search
  5920. * @param name defines the name to search
  5921. * @returns the behavior or null if not found
  5922. */
  5923. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5924. }
  5925. }
  5926. declare module BABYLON {
  5927. /**
  5928. * Defines an array and its length.
  5929. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5930. */
  5931. export interface ISmartArrayLike<T> {
  5932. /**
  5933. * The data of the array.
  5934. */
  5935. data: Array<T>;
  5936. /**
  5937. * The active length of the array.
  5938. */
  5939. length: number;
  5940. }
  5941. /**
  5942. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5943. */
  5944. export class SmartArray<T> implements ISmartArrayLike<T> {
  5945. /**
  5946. * The full set of data from the array.
  5947. */
  5948. data: Array<T>;
  5949. /**
  5950. * The active length of the array.
  5951. */
  5952. length: number;
  5953. protected _id: number;
  5954. /**
  5955. * Instantiates a Smart Array.
  5956. * @param capacity defines the default capacity of the array.
  5957. */
  5958. constructor(capacity: number);
  5959. /**
  5960. * Pushes a value at the end of the active data.
  5961. * @param value defines the object to push in the array.
  5962. */
  5963. push(value: T): void;
  5964. /**
  5965. * Iterates over the active data and apply the lambda to them.
  5966. * @param func defines the action to apply on each value.
  5967. */
  5968. forEach(func: (content: T) => void): void;
  5969. /**
  5970. * Sorts the full sets of data.
  5971. * @param compareFn defines the comparison function to apply.
  5972. */
  5973. sort(compareFn: (a: T, b: T) => number): void;
  5974. /**
  5975. * Resets the active data to an empty array.
  5976. */
  5977. reset(): void;
  5978. /**
  5979. * Releases all the data from the array as well as the array.
  5980. */
  5981. dispose(): void;
  5982. /**
  5983. * Concats the active data with a given array.
  5984. * @param array defines the data to concatenate with.
  5985. */
  5986. concat(array: any): void;
  5987. /**
  5988. * Returns the position of a value in the active data.
  5989. * @param value defines the value to find the index for
  5990. * @returns the index if found in the active data otherwise -1
  5991. */
  5992. indexOf(value: T): number;
  5993. /**
  5994. * Returns whether an element is part of the active data.
  5995. * @param value defines the value to look for
  5996. * @returns true if found in the active data otherwise false
  5997. */
  5998. contains(value: T): boolean;
  5999. private static _GlobalId;
  6000. }
  6001. /**
  6002. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6003. * The data in this array can only be present once
  6004. */
  6005. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6006. private _duplicateId;
  6007. /**
  6008. * Pushes a value at the end of the active data.
  6009. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6010. * @param value defines the object to push in the array.
  6011. */
  6012. push(value: T): void;
  6013. /**
  6014. * Pushes a value at the end of the active data.
  6015. * If the data is already present, it won t be added again
  6016. * @param value defines the object to push in the array.
  6017. * @returns true if added false if it was already present
  6018. */
  6019. pushNoDuplicate(value: T): boolean;
  6020. /**
  6021. * Resets the active data to an empty array.
  6022. */
  6023. reset(): void;
  6024. /**
  6025. * Concats the active data with a given array.
  6026. * This ensures no dupplicate will be present in the result.
  6027. * @param array defines the data to concatenate with.
  6028. */
  6029. concatWithNoDuplicate(array: any): void;
  6030. }
  6031. }
  6032. declare module BABYLON {
  6033. /**
  6034. * @ignore
  6035. * This is a list of all the different input types that are available in the application.
  6036. * Fo instance: ArcRotateCameraGamepadInput...
  6037. */
  6038. export var CameraInputTypes: {};
  6039. /**
  6040. * This is the contract to implement in order to create a new input class.
  6041. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6042. */
  6043. export interface ICameraInput<TCamera extends Camera> {
  6044. /**
  6045. * Defines the camera the input is attached to.
  6046. */
  6047. camera: Nullable<TCamera>;
  6048. /**
  6049. * Gets the class name of the current intput.
  6050. * @returns the class name
  6051. */
  6052. getClassName(): string;
  6053. /**
  6054. * Get the friendly name associated with the input class.
  6055. * @returns the input friendly name
  6056. */
  6057. getSimpleName(): string;
  6058. /**
  6059. * Attach the input controls to a specific dom element to get the input from.
  6060. * @param element Defines the element the controls should be listened from
  6061. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6062. */
  6063. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6064. /**
  6065. * Detach the current controls from the specified dom element.
  6066. * @param element Defines the element to stop listening the inputs from
  6067. */
  6068. detachControl(element: Nullable<HTMLElement>): void;
  6069. /**
  6070. * Update the current camera state depending on the inputs that have been used this frame.
  6071. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6072. */
  6073. checkInputs?: () => void;
  6074. }
  6075. /**
  6076. * Represents a map of input types to input instance or input index to input instance.
  6077. */
  6078. export interface CameraInputsMap<TCamera extends Camera> {
  6079. /**
  6080. * Accessor to the input by input type.
  6081. */
  6082. [name: string]: ICameraInput<TCamera>;
  6083. /**
  6084. * Accessor to the input by input index.
  6085. */
  6086. [idx: number]: ICameraInput<TCamera>;
  6087. }
  6088. /**
  6089. * This represents the input manager used within a camera.
  6090. * It helps dealing with all the different kind of input attached to a camera.
  6091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6092. */
  6093. export class CameraInputsManager<TCamera extends Camera> {
  6094. /**
  6095. * Defines the list of inputs attahed to the camera.
  6096. */
  6097. attached: CameraInputsMap<TCamera>;
  6098. /**
  6099. * Defines the dom element the camera is collecting inputs from.
  6100. * This is null if the controls have not been attached.
  6101. */
  6102. attachedElement: Nullable<HTMLElement>;
  6103. /**
  6104. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6105. */
  6106. noPreventDefault: boolean;
  6107. /**
  6108. * Defined the camera the input manager belongs to.
  6109. */
  6110. camera: TCamera;
  6111. /**
  6112. * Update the current camera state depending on the inputs that have been used this frame.
  6113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6114. */
  6115. checkInputs: () => void;
  6116. /**
  6117. * Instantiate a new Camera Input Manager.
  6118. * @param camera Defines the camera the input manager blongs to
  6119. */
  6120. constructor(camera: TCamera);
  6121. /**
  6122. * Add an input method to a camera
  6123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6124. * @param input camera input method
  6125. */
  6126. add(input: ICameraInput<TCamera>): void;
  6127. /**
  6128. * Remove a specific input method from a camera
  6129. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6130. * @param inputToRemove camera input method
  6131. */
  6132. remove(inputToRemove: ICameraInput<TCamera>): void;
  6133. /**
  6134. * Remove a specific input type from a camera
  6135. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6136. * @param inputType the type of the input to remove
  6137. */
  6138. removeByType(inputType: string): void;
  6139. private _addCheckInputs;
  6140. /**
  6141. * Attach the input controls to the currently attached dom element to listen the events from.
  6142. * @param input Defines the input to attach
  6143. */
  6144. attachInput(input: ICameraInput<TCamera>): void;
  6145. /**
  6146. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6147. * @param element Defines the dom element to collect the events from
  6148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6149. */
  6150. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6151. /**
  6152. * Detach the current manager inputs controls from a specific dom element.
  6153. * @param element Defines the dom element to collect the events from
  6154. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6155. */
  6156. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6157. /**
  6158. * Rebuild the dynamic inputCheck function from the current list of
  6159. * defined inputs in the manager.
  6160. */
  6161. rebuildInputCheck(): void;
  6162. /**
  6163. * Remove all attached input methods from a camera
  6164. */
  6165. clear(): void;
  6166. /**
  6167. * Serialize the current input manager attached to a camera.
  6168. * This ensures than once parsed,
  6169. * the input associated to the camera will be identical to the current ones
  6170. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6171. */
  6172. serialize(serializedCamera: any): void;
  6173. /**
  6174. * Parses an input manager serialized JSON to restore the previous list of inputs
  6175. * and states associated to a camera.
  6176. * @param parsedCamera Defines the JSON to parse
  6177. */
  6178. parse(parsedCamera: any): void;
  6179. }
  6180. }
  6181. declare module BABYLON {
  6182. /**
  6183. * Class used to store data that will be store in GPU memory
  6184. */
  6185. export class Buffer {
  6186. private _engine;
  6187. private _buffer;
  6188. /** @hidden */
  6189. _data: Nullable<DataArray>;
  6190. private _updatable;
  6191. private _instanced;
  6192. /**
  6193. * Gets the byte stride.
  6194. */
  6195. readonly byteStride: number;
  6196. /**
  6197. * Constructor
  6198. * @param engine the engine
  6199. * @param data the data to use for this buffer
  6200. * @param updatable whether the data is updatable
  6201. * @param stride the stride (optional)
  6202. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6203. * @param instanced whether the buffer is instanced (optional)
  6204. * @param useBytes set to true if the stride in in bytes (optional)
  6205. */
  6206. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6207. /**
  6208. * Create a new VertexBuffer based on the current buffer
  6209. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6210. * @param offset defines offset in the buffer (0 by default)
  6211. * @param size defines the size in floats of attributes (position is 3 for instance)
  6212. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6213. * @param instanced defines if the vertex buffer contains indexed data
  6214. * @param useBytes defines if the offset and stride are in bytes
  6215. * @returns the new vertex buffer
  6216. */
  6217. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6218. /**
  6219. * Gets a boolean indicating if the Buffer is updatable?
  6220. * @returns true if the buffer is updatable
  6221. */
  6222. isUpdatable(): boolean;
  6223. /**
  6224. * Gets current buffer's data
  6225. * @returns a DataArray or null
  6226. */
  6227. getData(): Nullable<DataArray>;
  6228. /**
  6229. * Gets underlying native buffer
  6230. * @returns underlying native buffer
  6231. */
  6232. getBuffer(): Nullable<DataBuffer>;
  6233. /**
  6234. * Gets the stride in float32 units (i.e. byte stride / 4).
  6235. * May not be an integer if the byte stride is not divisible by 4.
  6236. * DEPRECATED. Use byteStride instead.
  6237. * @returns the stride in float32 units
  6238. */
  6239. getStrideSize(): number;
  6240. /**
  6241. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6242. * @param data defines the data to store
  6243. */
  6244. create(data?: Nullable<DataArray>): void;
  6245. /** @hidden */
  6246. _rebuild(): void;
  6247. /**
  6248. * Update current buffer data
  6249. * @param data defines the data to store
  6250. */
  6251. update(data: DataArray): void;
  6252. /**
  6253. * Updates the data directly.
  6254. * @param data the new data
  6255. * @param offset the new offset
  6256. * @param vertexCount the vertex count (optional)
  6257. * @param useBytes set to true if the offset is in bytes
  6258. */
  6259. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6260. /**
  6261. * Release all resources
  6262. */
  6263. dispose(): void;
  6264. }
  6265. /**
  6266. * Specialized buffer used to store vertex data
  6267. */
  6268. export class VertexBuffer {
  6269. /** @hidden */
  6270. _buffer: Buffer;
  6271. private _kind;
  6272. private _size;
  6273. private _ownsBuffer;
  6274. private _instanced;
  6275. private _instanceDivisor;
  6276. /**
  6277. * The byte type.
  6278. */
  6279. static readonly BYTE: number;
  6280. /**
  6281. * The unsigned byte type.
  6282. */
  6283. static readonly UNSIGNED_BYTE: number;
  6284. /**
  6285. * The short type.
  6286. */
  6287. static readonly SHORT: number;
  6288. /**
  6289. * The unsigned short type.
  6290. */
  6291. static readonly UNSIGNED_SHORT: number;
  6292. /**
  6293. * The integer type.
  6294. */
  6295. static readonly INT: number;
  6296. /**
  6297. * The unsigned integer type.
  6298. */
  6299. static readonly UNSIGNED_INT: number;
  6300. /**
  6301. * The float type.
  6302. */
  6303. static readonly FLOAT: number;
  6304. /**
  6305. * Gets or sets the instance divisor when in instanced mode
  6306. */
  6307. instanceDivisor: number;
  6308. /**
  6309. * Gets the byte stride.
  6310. */
  6311. readonly byteStride: number;
  6312. /**
  6313. * Gets the byte offset.
  6314. */
  6315. readonly byteOffset: number;
  6316. /**
  6317. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6318. */
  6319. readonly normalized: boolean;
  6320. /**
  6321. * Gets the data type of each component in the array.
  6322. */
  6323. readonly type: number;
  6324. /**
  6325. * Constructor
  6326. * @param engine the engine
  6327. * @param data the data to use for this vertex buffer
  6328. * @param kind the vertex buffer kind
  6329. * @param updatable whether the data is updatable
  6330. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6331. * @param stride the stride (optional)
  6332. * @param instanced whether the buffer is instanced (optional)
  6333. * @param offset the offset of the data (optional)
  6334. * @param size the number of components (optional)
  6335. * @param type the type of the component (optional)
  6336. * @param normalized whether the data contains normalized data (optional)
  6337. * @param useBytes set to true if stride and offset are in bytes (optional)
  6338. */
  6339. 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);
  6340. /** @hidden */
  6341. _rebuild(): void;
  6342. /**
  6343. * Returns the kind of the VertexBuffer (string)
  6344. * @returns a string
  6345. */
  6346. getKind(): string;
  6347. /**
  6348. * Gets a boolean indicating if the VertexBuffer is updatable?
  6349. * @returns true if the buffer is updatable
  6350. */
  6351. isUpdatable(): boolean;
  6352. /**
  6353. * Gets current buffer's data
  6354. * @returns a DataArray or null
  6355. */
  6356. getData(): Nullable<DataArray>;
  6357. /**
  6358. * Gets underlying native buffer
  6359. * @returns underlying native buffer
  6360. */
  6361. getBuffer(): Nullable<DataBuffer>;
  6362. /**
  6363. * Gets the stride in float32 units (i.e. byte stride / 4).
  6364. * May not be an integer if the byte stride is not divisible by 4.
  6365. * DEPRECATED. Use byteStride instead.
  6366. * @returns the stride in float32 units
  6367. */
  6368. getStrideSize(): number;
  6369. /**
  6370. * Returns the offset as a multiple of the type byte length.
  6371. * DEPRECATED. Use byteOffset instead.
  6372. * @returns the offset in bytes
  6373. */
  6374. getOffset(): number;
  6375. /**
  6376. * Returns the number of components per vertex attribute (integer)
  6377. * @returns the size in float
  6378. */
  6379. getSize(): number;
  6380. /**
  6381. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6382. * @returns true if this buffer is instanced
  6383. */
  6384. getIsInstanced(): boolean;
  6385. /**
  6386. * Returns the instancing divisor, zero for non-instanced (integer).
  6387. * @returns a number
  6388. */
  6389. getInstanceDivisor(): number;
  6390. /**
  6391. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6392. * @param data defines the data to store
  6393. */
  6394. create(data?: DataArray): void;
  6395. /**
  6396. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6397. * This function will create a new buffer if the current one is not updatable
  6398. * @param data defines the data to store
  6399. */
  6400. update(data: DataArray): void;
  6401. /**
  6402. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6403. * Returns the directly updated WebGLBuffer.
  6404. * @param data the new data
  6405. * @param offset the new offset
  6406. * @param useBytes set to true if the offset is in bytes
  6407. */
  6408. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6409. /**
  6410. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6411. */
  6412. dispose(): void;
  6413. /**
  6414. * Enumerates each value of this vertex buffer as numbers.
  6415. * @param count the number of values to enumerate
  6416. * @param callback the callback function called for each value
  6417. */
  6418. forEach(count: number, callback: (value: number, index: number) => void): void;
  6419. /**
  6420. * Positions
  6421. */
  6422. static readonly PositionKind: string;
  6423. /**
  6424. * Normals
  6425. */
  6426. static readonly NormalKind: string;
  6427. /**
  6428. * Tangents
  6429. */
  6430. static readonly TangentKind: string;
  6431. /**
  6432. * Texture coordinates
  6433. */
  6434. static readonly UVKind: string;
  6435. /**
  6436. * Texture coordinates 2
  6437. */
  6438. static readonly UV2Kind: string;
  6439. /**
  6440. * Texture coordinates 3
  6441. */
  6442. static readonly UV3Kind: string;
  6443. /**
  6444. * Texture coordinates 4
  6445. */
  6446. static readonly UV4Kind: string;
  6447. /**
  6448. * Texture coordinates 5
  6449. */
  6450. static readonly UV5Kind: string;
  6451. /**
  6452. * Texture coordinates 6
  6453. */
  6454. static readonly UV6Kind: string;
  6455. /**
  6456. * Colors
  6457. */
  6458. static readonly ColorKind: string;
  6459. /**
  6460. * Matrix indices (for bones)
  6461. */
  6462. static readonly MatricesIndicesKind: string;
  6463. /**
  6464. * Matrix weights (for bones)
  6465. */
  6466. static readonly MatricesWeightsKind: string;
  6467. /**
  6468. * Additional matrix indices (for bones)
  6469. */
  6470. static readonly MatricesIndicesExtraKind: string;
  6471. /**
  6472. * Additional matrix weights (for bones)
  6473. */
  6474. static readonly MatricesWeightsExtraKind: string;
  6475. /**
  6476. * Deduces the stride given a kind.
  6477. * @param kind The kind string to deduce
  6478. * @returns The deduced stride
  6479. */
  6480. static DeduceStride(kind: string): number;
  6481. /**
  6482. * Gets the byte length of the given type.
  6483. * @param type the type
  6484. * @returns the number of bytes
  6485. */
  6486. static GetTypeByteLength(type: number): number;
  6487. /**
  6488. * Enumerates each value of the given parameters as numbers.
  6489. * @param data the data to enumerate
  6490. * @param byteOffset the byte offset of the data
  6491. * @param byteStride the byte stride of the data
  6492. * @param componentCount the number of components per element
  6493. * @param componentType the type of the component
  6494. * @param count the number of values to enumerate
  6495. * @param normalized whether the data is normalized
  6496. * @param callback the callback function called for each value
  6497. */
  6498. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6499. private static _GetFloatValue;
  6500. }
  6501. }
  6502. declare module BABYLON {
  6503. /**
  6504. * @hidden
  6505. */
  6506. export class IntersectionInfo {
  6507. bu: Nullable<number>;
  6508. bv: Nullable<number>;
  6509. distance: number;
  6510. faceId: number;
  6511. subMeshId: number;
  6512. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6513. }
  6514. }
  6515. declare module BABYLON {
  6516. /**
  6517. * Represens a plane by the equation ax + by + cz + d = 0
  6518. */
  6519. export class Plane {
  6520. private static _TmpMatrix;
  6521. /**
  6522. * Normal of the plane (a,b,c)
  6523. */
  6524. normal: Vector3;
  6525. /**
  6526. * d component of the plane
  6527. */
  6528. d: number;
  6529. /**
  6530. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6531. * @param a a component of the plane
  6532. * @param b b component of the plane
  6533. * @param c c component of the plane
  6534. * @param d d component of the plane
  6535. */
  6536. constructor(a: number, b: number, c: number, d: number);
  6537. /**
  6538. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6539. */
  6540. asArray(): number[];
  6541. /**
  6542. * @returns a new plane copied from the current Plane.
  6543. */
  6544. clone(): Plane;
  6545. /**
  6546. * @returns the string "Plane".
  6547. */
  6548. getClassName(): string;
  6549. /**
  6550. * @returns the Plane hash code.
  6551. */
  6552. getHashCode(): number;
  6553. /**
  6554. * Normalize the current Plane in place.
  6555. * @returns the updated Plane.
  6556. */
  6557. normalize(): Plane;
  6558. /**
  6559. * Applies a transformation the plane and returns the result
  6560. * @param transformation the transformation matrix to be applied to the plane
  6561. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6562. */
  6563. transform(transformation: DeepImmutable<Matrix>): Plane;
  6564. /**
  6565. * Calcualtte the dot product between the point and the plane normal
  6566. * @param point point to calculate the dot product with
  6567. * @returns the dot product (float) of the point coordinates and the plane normal.
  6568. */
  6569. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6570. /**
  6571. * Updates the current Plane from the plane defined by the three given points.
  6572. * @param point1 one of the points used to contruct the plane
  6573. * @param point2 one of the points used to contruct the plane
  6574. * @param point3 one of the points used to contruct the plane
  6575. * @returns the updated Plane.
  6576. */
  6577. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6578. /**
  6579. * Checks if the plane is facing a given direction
  6580. * @param direction the direction to check if the plane is facing
  6581. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6582. * @returns True is the vector "direction" is the same side than the plane normal.
  6583. */
  6584. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6585. /**
  6586. * Calculates the distance to a point
  6587. * @param point point to calculate distance to
  6588. * @returns the signed distance (float) from the given point to the Plane.
  6589. */
  6590. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6591. /**
  6592. * Creates a plane from an array
  6593. * @param array the array to create a plane from
  6594. * @returns a new Plane from the given array.
  6595. */
  6596. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6597. /**
  6598. * Creates a plane from three points
  6599. * @param point1 point used to create the plane
  6600. * @param point2 point used to create the plane
  6601. * @param point3 point used to create the plane
  6602. * @returns a new Plane defined by the three given points.
  6603. */
  6604. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6605. /**
  6606. * Creates a plane from an origin point and a normal
  6607. * @param origin origin of the plane to be constructed
  6608. * @param normal normal of the plane to be constructed
  6609. * @returns a new Plane the normal vector to this plane at the given origin point.
  6610. * Note : the vector "normal" is updated because normalized.
  6611. */
  6612. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6613. /**
  6614. * Calculates the distance from a plane and a point
  6615. * @param origin origin of the plane to be constructed
  6616. * @param normal normal of the plane to be constructed
  6617. * @param point point to calculate distance to
  6618. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6619. */
  6620. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6621. }
  6622. }
  6623. declare module BABYLON {
  6624. /**
  6625. * Class used to store bounding sphere information
  6626. */
  6627. export class BoundingSphere {
  6628. /**
  6629. * Gets the center of the bounding sphere in local space
  6630. */
  6631. readonly center: Vector3;
  6632. /**
  6633. * Radius of the bounding sphere in local space
  6634. */
  6635. radius: number;
  6636. /**
  6637. * Gets the center of the bounding sphere in world space
  6638. */
  6639. readonly centerWorld: Vector3;
  6640. /**
  6641. * Radius of the bounding sphere in world space
  6642. */
  6643. radiusWorld: number;
  6644. /**
  6645. * Gets the minimum vector in local space
  6646. */
  6647. readonly minimum: Vector3;
  6648. /**
  6649. * Gets the maximum vector in local space
  6650. */
  6651. readonly maximum: Vector3;
  6652. private _worldMatrix;
  6653. private static readonly TmpVector3;
  6654. /**
  6655. * Creates a new bounding sphere
  6656. * @param min defines the minimum vector (in local space)
  6657. * @param max defines the maximum vector (in local space)
  6658. * @param worldMatrix defines the new world matrix
  6659. */
  6660. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6661. /**
  6662. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6663. * @param min defines the new minimum vector (in local space)
  6664. * @param max defines the new maximum vector (in local space)
  6665. * @param worldMatrix defines the new world matrix
  6666. */
  6667. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6668. /**
  6669. * Scale the current bounding sphere by applying a scale factor
  6670. * @param factor defines the scale factor to apply
  6671. * @returns the current bounding box
  6672. */
  6673. scale(factor: number): BoundingSphere;
  6674. /**
  6675. * Gets the world matrix of the bounding box
  6676. * @returns a matrix
  6677. */
  6678. getWorldMatrix(): DeepImmutable<Matrix>;
  6679. /** @hidden */
  6680. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6681. /**
  6682. * Tests if the bounding sphere is intersecting the frustum planes
  6683. * @param frustumPlanes defines the frustum planes to test
  6684. * @returns true if there is an intersection
  6685. */
  6686. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6687. /**
  6688. * Tests if the bounding sphere center is in between the frustum planes.
  6689. * Used for optimistic fast inclusion.
  6690. * @param frustumPlanes defines the frustum planes to test
  6691. * @returns true if the sphere center is in between the frustum planes
  6692. */
  6693. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6694. /**
  6695. * Tests if a point is inside the bounding sphere
  6696. * @param point defines the point to test
  6697. * @returns true if the point is inside the bounding sphere
  6698. */
  6699. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6700. /**
  6701. * Checks if two sphere intersct
  6702. * @param sphere0 sphere 0
  6703. * @param sphere1 sphere 1
  6704. * @returns true if the speres intersect
  6705. */
  6706. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6707. }
  6708. }
  6709. declare module BABYLON {
  6710. /**
  6711. * Class used to store bounding box information
  6712. */
  6713. export class BoundingBox implements ICullable {
  6714. /**
  6715. * Gets the 8 vectors representing the bounding box in local space
  6716. */
  6717. readonly vectors: Vector3[];
  6718. /**
  6719. * Gets the center of the bounding box in local space
  6720. */
  6721. readonly center: Vector3;
  6722. /**
  6723. * Gets the center of the bounding box in world space
  6724. */
  6725. readonly centerWorld: Vector3;
  6726. /**
  6727. * Gets the extend size in local space
  6728. */
  6729. readonly extendSize: Vector3;
  6730. /**
  6731. * Gets the extend size in world space
  6732. */
  6733. readonly extendSizeWorld: Vector3;
  6734. /**
  6735. * Gets the OBB (object bounding box) directions
  6736. */
  6737. readonly directions: Vector3[];
  6738. /**
  6739. * Gets the 8 vectors representing the bounding box in world space
  6740. */
  6741. readonly vectorsWorld: Vector3[];
  6742. /**
  6743. * Gets the minimum vector in world space
  6744. */
  6745. readonly minimumWorld: Vector3;
  6746. /**
  6747. * Gets the maximum vector in world space
  6748. */
  6749. readonly maximumWorld: Vector3;
  6750. /**
  6751. * Gets the minimum vector in local space
  6752. */
  6753. readonly minimum: Vector3;
  6754. /**
  6755. * Gets the maximum vector in local space
  6756. */
  6757. readonly maximum: Vector3;
  6758. private _worldMatrix;
  6759. private static readonly TmpVector3;
  6760. /**
  6761. * @hidden
  6762. */
  6763. _tag: number;
  6764. /**
  6765. * Creates a new bounding box
  6766. * @param min defines the minimum vector (in local space)
  6767. * @param max defines the maximum vector (in local space)
  6768. * @param worldMatrix defines the new world matrix
  6769. */
  6770. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6771. /**
  6772. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6773. * @param min defines the new minimum vector (in local space)
  6774. * @param max defines the new maximum vector (in local space)
  6775. * @param worldMatrix defines the new world matrix
  6776. */
  6777. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6778. /**
  6779. * Scale the current bounding box by applying a scale factor
  6780. * @param factor defines the scale factor to apply
  6781. * @returns the current bounding box
  6782. */
  6783. scale(factor: number): BoundingBox;
  6784. /**
  6785. * Gets the world matrix of the bounding box
  6786. * @returns a matrix
  6787. */
  6788. getWorldMatrix(): DeepImmutable<Matrix>;
  6789. /** @hidden */
  6790. _update(world: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Tests if the bounding box is intersecting the frustum planes
  6793. * @param frustumPlanes defines the frustum planes to test
  6794. * @returns true if there is an intersection
  6795. */
  6796. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6797. /**
  6798. * Tests if the bounding box is entirely inside the frustum planes
  6799. * @param frustumPlanes defines the frustum planes to test
  6800. * @returns true if there is an inclusion
  6801. */
  6802. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6803. /**
  6804. * Tests if a point is inside the bounding box
  6805. * @param point defines the point to test
  6806. * @returns true if the point is inside the bounding box
  6807. */
  6808. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6809. /**
  6810. * Tests if the bounding box intersects with a bounding sphere
  6811. * @param sphere defines the sphere to test
  6812. * @returns true if there is an intersection
  6813. */
  6814. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6815. /**
  6816. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6817. * @param min defines the min vector to use
  6818. * @param max defines the max vector to use
  6819. * @returns true if there is an intersection
  6820. */
  6821. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6822. /**
  6823. * Tests if two bounding boxes are intersections
  6824. * @param box0 defines the first box to test
  6825. * @param box1 defines the second box to test
  6826. * @returns true if there is an intersection
  6827. */
  6828. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6829. /**
  6830. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6831. * @param minPoint defines the minimum vector of the bounding box
  6832. * @param maxPoint defines the maximum vector of the bounding box
  6833. * @param sphereCenter defines the sphere center
  6834. * @param sphereRadius defines the sphere radius
  6835. * @returns true if there is an intersection
  6836. */
  6837. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6838. /**
  6839. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6840. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6841. * @param frustumPlanes defines the frustum planes to test
  6842. * @return true if there is an inclusion
  6843. */
  6844. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6845. /**
  6846. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6847. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6848. * @param frustumPlanes defines the frustum planes to test
  6849. * @return true if there is an intersection
  6850. */
  6851. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6852. }
  6853. }
  6854. declare module BABYLON {
  6855. /** @hidden */
  6856. export class Collider {
  6857. /** Define if a collision was found */
  6858. collisionFound: boolean;
  6859. /**
  6860. * Define last intersection point in local space
  6861. */
  6862. intersectionPoint: Vector3;
  6863. /**
  6864. * Define last collided mesh
  6865. */
  6866. collidedMesh: Nullable<AbstractMesh>;
  6867. private _collisionPoint;
  6868. private _planeIntersectionPoint;
  6869. private _tempVector;
  6870. private _tempVector2;
  6871. private _tempVector3;
  6872. private _tempVector4;
  6873. private _edge;
  6874. private _baseToVertex;
  6875. private _destinationPoint;
  6876. private _slidePlaneNormal;
  6877. private _displacementVector;
  6878. /** @hidden */
  6879. _radius: Vector3;
  6880. /** @hidden */
  6881. _retry: number;
  6882. private _velocity;
  6883. private _basePoint;
  6884. private _epsilon;
  6885. /** @hidden */
  6886. _velocityWorldLength: number;
  6887. /** @hidden */
  6888. _basePointWorld: Vector3;
  6889. private _velocityWorld;
  6890. private _normalizedVelocity;
  6891. /** @hidden */
  6892. _initialVelocity: Vector3;
  6893. /** @hidden */
  6894. _initialPosition: Vector3;
  6895. private _nearestDistance;
  6896. private _collisionMask;
  6897. collisionMask: number;
  6898. /**
  6899. * Gets the plane normal used to compute the sliding response (in local space)
  6900. */
  6901. readonly slidePlaneNormal: Vector3;
  6902. /** @hidden */
  6903. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6904. /** @hidden */
  6905. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6906. /** @hidden */
  6907. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6908. /** @hidden */
  6909. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6910. /** @hidden */
  6911. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6912. /** @hidden */
  6913. _getResponse(pos: Vector3, vel: Vector3): void;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Interface for cullable objects
  6919. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6920. */
  6921. export interface ICullable {
  6922. /**
  6923. * Checks if the object or part of the object is in the frustum
  6924. * @param frustumPlanes Camera near/planes
  6925. * @returns true if the object is in frustum otherwise false
  6926. */
  6927. isInFrustum(frustumPlanes: Plane[]): boolean;
  6928. /**
  6929. * Checks if a cullable object (mesh...) is in the camera frustum
  6930. * Unlike isInFrustum this cheks the full bounding box
  6931. * @param frustumPlanes Camera near/planes
  6932. * @returns true if the object is in frustum otherwise false
  6933. */
  6934. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6935. }
  6936. /**
  6937. * Info for a bounding data of a mesh
  6938. */
  6939. export class BoundingInfo implements ICullable {
  6940. /**
  6941. * Bounding box for the mesh
  6942. */
  6943. readonly boundingBox: BoundingBox;
  6944. /**
  6945. * Bounding sphere for the mesh
  6946. */
  6947. readonly boundingSphere: BoundingSphere;
  6948. private _isLocked;
  6949. private static readonly TmpVector3;
  6950. /**
  6951. * Constructs bounding info
  6952. * @param minimum min vector of the bounding box/sphere
  6953. * @param maximum max vector of the bounding box/sphere
  6954. * @param worldMatrix defines the new world matrix
  6955. */
  6956. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6957. /**
  6958. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6959. * @param min defines the new minimum vector (in local space)
  6960. * @param max defines the new maximum vector (in local space)
  6961. * @param worldMatrix defines the new world matrix
  6962. */
  6963. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6964. /**
  6965. * min vector of the bounding box/sphere
  6966. */
  6967. readonly minimum: Vector3;
  6968. /**
  6969. * max vector of the bounding box/sphere
  6970. */
  6971. readonly maximum: Vector3;
  6972. /**
  6973. * If the info is locked and won't be updated to avoid perf overhead
  6974. */
  6975. isLocked: boolean;
  6976. /**
  6977. * Updates the bounding sphere and box
  6978. * @param world world matrix to be used to update
  6979. */
  6980. update(world: DeepImmutable<Matrix>): void;
  6981. /**
  6982. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6983. * @param center New center of the bounding info
  6984. * @param extend New extend of the bounding info
  6985. * @returns the current bounding info
  6986. */
  6987. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6988. /**
  6989. * Scale the current bounding info by applying a scale factor
  6990. * @param factor defines the scale factor to apply
  6991. * @returns the current bounding info
  6992. */
  6993. scale(factor: number): BoundingInfo;
  6994. /**
  6995. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6996. * @param frustumPlanes defines the frustum to test
  6997. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6998. * @returns true if the bounding info is in the frustum planes
  6999. */
  7000. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7001. /**
  7002. * Gets the world distance between the min and max points of the bounding box
  7003. */
  7004. readonly diagonalLength: number;
  7005. /**
  7006. * Checks if a cullable object (mesh...) is in the camera frustum
  7007. * Unlike isInFrustum this cheks the full bounding box
  7008. * @param frustumPlanes Camera near/planes
  7009. * @returns true if the object is in frustum otherwise false
  7010. */
  7011. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7012. /** @hidden */
  7013. _checkCollision(collider: Collider): boolean;
  7014. /**
  7015. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7016. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7017. * @param point the point to check intersection with
  7018. * @returns if the point intersects
  7019. */
  7020. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7021. /**
  7022. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7023. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7024. * @param boundingInfo the bounding info to check intersection with
  7025. * @param precise if the intersection should be done using OBB
  7026. * @returns if the bounding info intersects
  7027. */
  7028. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7029. }
  7030. }
  7031. declare module BABYLON {
  7032. /**
  7033. * Extracts minimum and maximum values from a list of indexed positions
  7034. * @param positions defines the positions to use
  7035. * @param indices defines the indices to the positions
  7036. * @param indexStart defines the start index
  7037. * @param indexCount defines the end index
  7038. * @param bias defines bias value to add to the result
  7039. * @return minimum and maximum values
  7040. */
  7041. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7042. minimum: Vector3;
  7043. maximum: Vector3;
  7044. };
  7045. /**
  7046. * Extracts minimum and maximum values from a list of positions
  7047. * @param positions defines the positions to use
  7048. * @param start defines the start index in the positions array
  7049. * @param count defines the number of positions to handle
  7050. * @param bias defines bias value to add to the result
  7051. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7052. * @return minimum and maximum values
  7053. */
  7054. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7055. minimum: Vector3;
  7056. maximum: Vector3;
  7057. };
  7058. }
  7059. declare module BABYLON {
  7060. /** @hidden */
  7061. export class WebGLDataBuffer extends DataBuffer {
  7062. private _buffer;
  7063. constructor(resource: WebGLBuffer);
  7064. readonly underlyingResource: any;
  7065. }
  7066. }
  7067. declare module BABYLON {
  7068. /** @hidden */
  7069. export class WebGLPipelineContext implements IPipelineContext {
  7070. engine: ThinEngine;
  7071. program: Nullable<WebGLProgram>;
  7072. context?: WebGLRenderingContext;
  7073. vertexShader?: WebGLShader;
  7074. fragmentShader?: WebGLShader;
  7075. isParallelCompiled: boolean;
  7076. onCompiled?: () => void;
  7077. transformFeedback?: WebGLTransformFeedback | null;
  7078. readonly isAsync: boolean;
  7079. readonly isReady: boolean;
  7080. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7081. }
  7082. }
  7083. declare module BABYLON {
  7084. interface ThinEngine {
  7085. /**
  7086. * Create an uniform buffer
  7087. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7088. * @param elements defines the content of the uniform buffer
  7089. * @returns the webGL uniform buffer
  7090. */
  7091. createUniformBuffer(elements: FloatArray): DataBuffer;
  7092. /**
  7093. * Create a dynamic uniform buffer
  7094. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7095. * @param elements defines the content of the uniform buffer
  7096. * @returns the webGL uniform buffer
  7097. */
  7098. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7099. /**
  7100. * Update an existing uniform buffer
  7101. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7102. * @param uniformBuffer defines the target uniform buffer
  7103. * @param elements defines the content to update
  7104. * @param offset defines the offset in the uniform buffer where update should start
  7105. * @param count defines the size of the data to update
  7106. */
  7107. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7108. /**
  7109. * Bind an uniform buffer to the current webGL context
  7110. * @param buffer defines the buffer to bind
  7111. */
  7112. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7113. /**
  7114. * Bind a buffer to the current webGL context at a given location
  7115. * @param buffer defines the buffer to bind
  7116. * @param location defines the index where to bind the buffer
  7117. */
  7118. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7119. /**
  7120. * Bind a specific block at a given index in a specific shader program
  7121. * @param pipelineContext defines the pipeline context to use
  7122. * @param blockName defines the block name
  7123. * @param index defines the index where to bind the block
  7124. */
  7125. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7126. }
  7127. }
  7128. declare module BABYLON {
  7129. /**
  7130. * Uniform buffer objects.
  7131. *
  7132. * Handles blocks of uniform on the GPU.
  7133. *
  7134. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7135. *
  7136. * For more information, please refer to :
  7137. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7138. */
  7139. export class UniformBuffer {
  7140. private _engine;
  7141. private _buffer;
  7142. private _data;
  7143. private _bufferData;
  7144. private _dynamic?;
  7145. private _uniformLocations;
  7146. private _uniformSizes;
  7147. private _uniformLocationPointer;
  7148. private _needSync;
  7149. private _noUBO;
  7150. private _currentEffect;
  7151. private static _MAX_UNIFORM_SIZE;
  7152. private static _tempBuffer;
  7153. /**
  7154. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7155. * This is dynamic to allow compat with webgl 1 and 2.
  7156. * You will need to pass the name of the uniform as well as the value.
  7157. */
  7158. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7159. /**
  7160. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7161. * This is dynamic to allow compat with webgl 1 and 2.
  7162. * You will need to pass the name of the uniform as well as the value.
  7163. */
  7164. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7165. /**
  7166. * Lambda to Update a single float in a uniform buffer.
  7167. * This is dynamic to allow compat with webgl 1 and 2.
  7168. * You will need to pass the name of the uniform as well as the value.
  7169. */
  7170. updateFloat: (name: string, x: number) => void;
  7171. /**
  7172. * Lambda to Update a vec2 of float in a uniform buffer.
  7173. * This is dynamic to allow compat with webgl 1 and 2.
  7174. * You will need to pass the name of the uniform as well as the value.
  7175. */
  7176. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7177. /**
  7178. * Lambda to Update a vec3 of float in a uniform buffer.
  7179. * This is dynamic to allow compat with webgl 1 and 2.
  7180. * You will need to pass the name of the uniform as well as the value.
  7181. */
  7182. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7183. /**
  7184. * Lambda to Update a vec4 of float in a uniform buffer.
  7185. * This is dynamic to allow compat with webgl 1 and 2.
  7186. * You will need to pass the name of the uniform as well as the value.
  7187. */
  7188. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7189. /**
  7190. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7191. * This is dynamic to allow compat with webgl 1 and 2.
  7192. * You will need to pass the name of the uniform as well as the value.
  7193. */
  7194. updateMatrix: (name: string, mat: Matrix) => void;
  7195. /**
  7196. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7197. * This is dynamic to allow compat with webgl 1 and 2.
  7198. * You will need to pass the name of the uniform as well as the value.
  7199. */
  7200. updateVector3: (name: string, vector: Vector3) => void;
  7201. /**
  7202. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7203. * This is dynamic to allow compat with webgl 1 and 2.
  7204. * You will need to pass the name of the uniform as well as the value.
  7205. */
  7206. updateVector4: (name: string, vector: Vector4) => void;
  7207. /**
  7208. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7209. * This is dynamic to allow compat with webgl 1 and 2.
  7210. * You will need to pass the name of the uniform as well as the value.
  7211. */
  7212. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7213. /**
  7214. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7215. * This is dynamic to allow compat with webgl 1 and 2.
  7216. * You will need to pass the name of the uniform as well as the value.
  7217. */
  7218. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7219. /**
  7220. * Instantiates a new Uniform buffer objects.
  7221. *
  7222. * Handles blocks of uniform on the GPU.
  7223. *
  7224. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7225. *
  7226. * For more information, please refer to :
  7227. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7228. * @param engine Define the engine the buffer is associated with
  7229. * @param data Define the data contained in the buffer
  7230. * @param dynamic Define if the buffer is updatable
  7231. */
  7232. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7233. /**
  7234. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7235. * or just falling back on setUniformXXX calls.
  7236. */
  7237. readonly useUbo: boolean;
  7238. /**
  7239. * Indicates if the WebGL underlying uniform buffer is in sync
  7240. * with the javascript cache data.
  7241. */
  7242. readonly isSync: boolean;
  7243. /**
  7244. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7245. * Also, a dynamic UniformBuffer will disable cache verification and always
  7246. * update the underlying WebGL uniform buffer to the GPU.
  7247. * @returns if Dynamic, otherwise false
  7248. */
  7249. isDynamic(): boolean;
  7250. /**
  7251. * The data cache on JS side.
  7252. * @returns the underlying data as a float array
  7253. */
  7254. getData(): Float32Array;
  7255. /**
  7256. * The underlying WebGL Uniform buffer.
  7257. * @returns the webgl buffer
  7258. */
  7259. getBuffer(): Nullable<DataBuffer>;
  7260. /**
  7261. * std140 layout specifies how to align data within an UBO structure.
  7262. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7263. * for specs.
  7264. */
  7265. private _fillAlignment;
  7266. /**
  7267. * Adds an uniform in the buffer.
  7268. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7269. * for the layout to be correct !
  7270. * @param name Name of the uniform, as used in the uniform block in the shader.
  7271. * @param size Data size, or data directly.
  7272. */
  7273. addUniform(name: string, size: number | number[]): void;
  7274. /**
  7275. * Adds a Matrix 4x4 to the uniform buffer.
  7276. * @param name Name of the uniform, as used in the uniform block in the shader.
  7277. * @param mat A 4x4 matrix.
  7278. */
  7279. addMatrix(name: string, mat: Matrix): void;
  7280. /**
  7281. * Adds a vec2 to the uniform buffer.
  7282. * @param name Name of the uniform, as used in the uniform block in the shader.
  7283. * @param x Define the x component value of the vec2
  7284. * @param y Define the y component value of the vec2
  7285. */
  7286. addFloat2(name: string, x: number, y: number): void;
  7287. /**
  7288. * Adds a vec3 to the uniform buffer.
  7289. * @param name Name of the uniform, as used in the uniform block in the shader.
  7290. * @param x Define the x component value of the vec3
  7291. * @param y Define the y component value of the vec3
  7292. * @param z Define the z component value of the vec3
  7293. */
  7294. addFloat3(name: string, x: number, y: number, z: number): void;
  7295. /**
  7296. * Adds a vec3 to the uniform buffer.
  7297. * @param name Name of the uniform, as used in the uniform block in the shader.
  7298. * @param color Define the vec3 from a Color
  7299. */
  7300. addColor3(name: string, color: Color3): void;
  7301. /**
  7302. * Adds a vec4 to the uniform buffer.
  7303. * @param name Name of the uniform, as used in the uniform block in the shader.
  7304. * @param color Define the rgb components from a Color
  7305. * @param alpha Define the a component of the vec4
  7306. */
  7307. addColor4(name: string, color: Color3, alpha: number): void;
  7308. /**
  7309. * Adds a vec3 to the uniform buffer.
  7310. * @param name Name of the uniform, as used in the uniform block in the shader.
  7311. * @param vector Define the vec3 components from a Vector
  7312. */
  7313. addVector3(name: string, vector: Vector3): void;
  7314. /**
  7315. * Adds a Matrix 3x3 to the uniform buffer.
  7316. * @param name Name of the uniform, as used in the uniform block in the shader.
  7317. */
  7318. addMatrix3x3(name: string): void;
  7319. /**
  7320. * Adds a Matrix 2x2 to the uniform buffer.
  7321. * @param name Name of the uniform, as used in the uniform block in the shader.
  7322. */
  7323. addMatrix2x2(name: string): void;
  7324. /**
  7325. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7326. */
  7327. create(): void;
  7328. /** @hidden */
  7329. _rebuild(): void;
  7330. /**
  7331. * Updates the WebGL Uniform Buffer on the GPU.
  7332. * If the `dynamic` flag is set to true, no cache comparison is done.
  7333. * Otherwise, the buffer will be updated only if the cache differs.
  7334. */
  7335. update(): void;
  7336. /**
  7337. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7338. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7339. * @param data Define the flattened data
  7340. * @param size Define the size of the data.
  7341. */
  7342. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7343. private _valueCache;
  7344. private _cacheMatrix;
  7345. private _updateMatrix3x3ForUniform;
  7346. private _updateMatrix3x3ForEffect;
  7347. private _updateMatrix2x2ForEffect;
  7348. private _updateMatrix2x2ForUniform;
  7349. private _updateFloatForEffect;
  7350. private _updateFloatForUniform;
  7351. private _updateFloat2ForEffect;
  7352. private _updateFloat2ForUniform;
  7353. private _updateFloat3ForEffect;
  7354. private _updateFloat3ForUniform;
  7355. private _updateFloat4ForEffect;
  7356. private _updateFloat4ForUniform;
  7357. private _updateMatrixForEffect;
  7358. private _updateMatrixForUniform;
  7359. private _updateVector3ForEffect;
  7360. private _updateVector3ForUniform;
  7361. private _updateVector4ForEffect;
  7362. private _updateVector4ForUniform;
  7363. private _updateColor3ForEffect;
  7364. private _updateColor3ForUniform;
  7365. private _updateColor4ForEffect;
  7366. private _updateColor4ForUniform;
  7367. /**
  7368. * Sets a sampler uniform on the effect.
  7369. * @param name Define the name of the sampler.
  7370. * @param texture Define the texture to set in the sampler
  7371. */
  7372. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7373. /**
  7374. * Directly updates the value of the uniform in the cache AND on the GPU.
  7375. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7376. * @param data Define the flattened data
  7377. */
  7378. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7379. /**
  7380. * Binds this uniform buffer to an effect.
  7381. * @param effect Define the effect to bind the buffer to
  7382. * @param name Name of the uniform block in the shader.
  7383. */
  7384. bindToEffect(effect: Effect, name: string): void;
  7385. /**
  7386. * Disposes the uniform buffer.
  7387. */
  7388. dispose(): void;
  7389. }
  7390. }
  7391. declare module BABYLON {
  7392. /**
  7393. * Enum that determines the text-wrapping mode to use.
  7394. */
  7395. export enum InspectableType {
  7396. /**
  7397. * Checkbox for booleans
  7398. */
  7399. Checkbox = 0,
  7400. /**
  7401. * Sliders for numbers
  7402. */
  7403. Slider = 1,
  7404. /**
  7405. * Vector3
  7406. */
  7407. Vector3 = 2,
  7408. /**
  7409. * Quaternions
  7410. */
  7411. Quaternion = 3,
  7412. /**
  7413. * Color3
  7414. */
  7415. Color3 = 4,
  7416. /**
  7417. * String
  7418. */
  7419. String = 5
  7420. }
  7421. /**
  7422. * Interface used to define custom inspectable properties.
  7423. * This interface is used by the inspector to display custom property grids
  7424. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7425. */
  7426. export interface IInspectable {
  7427. /**
  7428. * Gets the label to display
  7429. */
  7430. label: string;
  7431. /**
  7432. * Gets the name of the property to edit
  7433. */
  7434. propertyName: string;
  7435. /**
  7436. * Gets the type of the editor to use
  7437. */
  7438. type: InspectableType;
  7439. /**
  7440. * Gets the minimum value of the property when using in "slider" mode
  7441. */
  7442. min?: number;
  7443. /**
  7444. * Gets the maximum value of the property when using in "slider" mode
  7445. */
  7446. max?: number;
  7447. /**
  7448. * Gets the setp to use when using in "slider" mode
  7449. */
  7450. step?: number;
  7451. }
  7452. }
  7453. declare module BABYLON {
  7454. /**
  7455. * Class used to provide helper for timing
  7456. */
  7457. export class TimingTools {
  7458. /**
  7459. * Polyfill for setImmediate
  7460. * @param action defines the action to execute after the current execution block
  7461. */
  7462. static SetImmediate(action: () => void): void;
  7463. }
  7464. }
  7465. declare module BABYLON {
  7466. /**
  7467. * Class used to enable instatition of objects by class name
  7468. */
  7469. export class InstantiationTools {
  7470. /**
  7471. * Use this object to register external classes like custom textures or material
  7472. * to allow the laoders to instantiate them
  7473. */
  7474. static RegisteredExternalClasses: {
  7475. [key: string]: Object;
  7476. };
  7477. /**
  7478. * Tries to instantiate a new object from a given class name
  7479. * @param className defines the class name to instantiate
  7480. * @returns the new object or null if the system was not able to do the instantiation
  7481. */
  7482. static Instantiate(className: string): any;
  7483. }
  7484. }
  7485. declare module BABYLON {
  7486. /**
  7487. * Define options used to create a depth texture
  7488. */
  7489. export class DepthTextureCreationOptions {
  7490. /** Specifies whether or not a stencil should be allocated in the texture */
  7491. generateStencil?: boolean;
  7492. /** Specifies whether or not bilinear filtering is enable on the texture */
  7493. bilinearFiltering?: boolean;
  7494. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7495. comparisonFunction?: number;
  7496. /** Specifies if the created texture is a cube texture */
  7497. isCube?: boolean;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. interface ThinEngine {
  7502. /**
  7503. * Creates a depth stencil cube texture.
  7504. * This is only available in WebGL 2.
  7505. * @param size The size of face edge in the cube texture.
  7506. * @param options The options defining the cube texture.
  7507. * @returns The cube texture
  7508. */
  7509. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7510. /**
  7511. * Creates a cube texture
  7512. * @param rootUrl defines the url where the files to load is located
  7513. * @param scene defines the current scene
  7514. * @param files defines the list of files to load (1 per face)
  7515. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7516. * @param onLoad defines an optional callback raised when the texture is loaded
  7517. * @param onError defines an optional callback raised if there is an issue to load the texture
  7518. * @param format defines the format of the data
  7519. * @param forcedExtension defines the extension to use to pick the right loader
  7520. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7521. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7522. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7523. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7524. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7525. * @returns the cube texture as an InternalTexture
  7526. */
  7527. 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;
  7528. /**
  7529. * Creates a cube texture
  7530. * @param rootUrl defines the url where the files to load is located
  7531. * @param scene defines the current scene
  7532. * @param files defines the list of files to load (1 per face)
  7533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7534. * @param onLoad defines an optional callback raised when the texture is loaded
  7535. * @param onError defines an optional callback raised if there is an issue to load the texture
  7536. * @param format defines the format of the data
  7537. * @param forcedExtension defines the extension to use to pick the right loader
  7538. * @returns the cube texture as an InternalTexture
  7539. */
  7540. 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;
  7541. /**
  7542. * Creates a cube texture
  7543. * @param rootUrl defines the url where the files to load is located
  7544. * @param scene defines the current scene
  7545. * @param files defines the list of files to load (1 per face)
  7546. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7547. * @param onLoad defines an optional callback raised when the texture is loaded
  7548. * @param onError defines an optional callback raised if there is an issue to load the texture
  7549. * @param format defines the format of the data
  7550. * @param forcedExtension defines the extension to use to pick the right loader
  7551. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7552. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7553. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7554. * @returns the cube texture as an InternalTexture
  7555. */
  7556. 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;
  7557. /** @hidden */
  7558. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7559. /** @hidden */
  7560. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7561. /** @hidden */
  7562. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7563. /** @hidden */
  7564. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7565. }
  7566. }
  7567. declare module BABYLON {
  7568. /**
  7569. * Class for creating a cube texture
  7570. */
  7571. export class CubeTexture extends BaseTexture {
  7572. private _delayedOnLoad;
  7573. /**
  7574. * The url of the texture
  7575. */
  7576. url: string;
  7577. /**
  7578. * Gets or sets the center of the bounding box associated with the cube texture.
  7579. * It must define where the camera used to render the texture was set
  7580. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7581. */
  7582. boundingBoxPosition: Vector3;
  7583. private _boundingBoxSize;
  7584. /**
  7585. * Gets or sets the size of the bounding box associated with the cube texture
  7586. * When defined, the cubemap will switch to local mode
  7587. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7588. * @example https://www.babylonjs-playground.com/#RNASML
  7589. */
  7590. /**
  7591. * Returns the bounding box size
  7592. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7593. */
  7594. boundingBoxSize: Vector3;
  7595. protected _rotationY: number;
  7596. /**
  7597. * Sets texture matrix rotation angle around Y axis in radians.
  7598. */
  7599. /**
  7600. * Gets texture matrix rotation angle around Y axis radians.
  7601. */
  7602. rotationY: number;
  7603. /**
  7604. * Are mip maps generated for this texture or not.
  7605. */
  7606. readonly noMipmap: boolean;
  7607. private _noMipmap;
  7608. private _files;
  7609. private _extensions;
  7610. private _textureMatrix;
  7611. private _format;
  7612. private _createPolynomials;
  7613. /** @hidden */
  7614. _prefiltered: boolean;
  7615. /**
  7616. * Creates a cube texture from an array of image urls
  7617. * @param files defines an array of image urls
  7618. * @param scene defines the hosting scene
  7619. * @param noMipmap specifies if mip maps are not used
  7620. * @returns a cube texture
  7621. */
  7622. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7623. /**
  7624. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7625. * @param url defines the url of the prefiltered texture
  7626. * @param scene defines the scene the texture is attached to
  7627. * @param forcedExtension defines the extension of the file if different from the url
  7628. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7629. * @return the prefiltered texture
  7630. */
  7631. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7632. /**
  7633. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7634. * as prefiltered data.
  7635. * @param rootUrl defines the url of the texture or the root name of the six images
  7636. * @param scene defines the scene the texture is attached to
  7637. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7638. * @param noMipmap defines if mipmaps should be created or not
  7639. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7640. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7641. * @param onError defines a callback triggered in case of error during load
  7642. * @param format defines the internal format to use for the texture once loaded
  7643. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7644. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7645. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7646. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7647. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7648. * @return the cube texture
  7649. */
  7650. 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);
  7651. /**
  7652. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7653. */
  7654. readonly isPrefiltered: boolean;
  7655. /**
  7656. * Get the current class name of the texture useful for serialization or dynamic coding.
  7657. * @returns "CubeTexture"
  7658. */
  7659. getClassName(): string;
  7660. /**
  7661. * Update the url (and optional buffer) of this texture if url was null during construction.
  7662. * @param url the url of the texture
  7663. * @param forcedExtension defines the extension to use
  7664. * @param onLoad callback called when the texture is loaded (defaults to null)
  7665. */
  7666. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7667. /**
  7668. * Delays loading of the cube texture
  7669. * @param forcedExtension defines the extension to use
  7670. */
  7671. delayLoad(forcedExtension?: string): void;
  7672. /**
  7673. * Returns the reflection texture matrix
  7674. * @returns the reflection texture matrix
  7675. */
  7676. getReflectionTextureMatrix(): Matrix;
  7677. /**
  7678. * Sets the reflection texture matrix
  7679. * @param value Reflection texture matrix
  7680. */
  7681. setReflectionTextureMatrix(value: Matrix): void;
  7682. /**
  7683. * Parses text to create a cube texture
  7684. * @param parsedTexture define the serialized text to read from
  7685. * @param scene defines the hosting scene
  7686. * @param rootUrl defines the root url of the cube texture
  7687. * @returns a cube texture
  7688. */
  7689. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7690. /**
  7691. * Makes a clone, or deep copy, of the cube texture
  7692. * @returns a new cube texture
  7693. */
  7694. clone(): CubeTexture;
  7695. }
  7696. }
  7697. declare module BABYLON {
  7698. /**
  7699. * Manages the defines for the Material
  7700. */
  7701. export class MaterialDefines {
  7702. /** @hidden */
  7703. protected _keys: string[];
  7704. private _isDirty;
  7705. /** @hidden */
  7706. _renderId: number;
  7707. /** @hidden */
  7708. _areLightsDirty: boolean;
  7709. /** @hidden */
  7710. _areLightsDisposed: boolean;
  7711. /** @hidden */
  7712. _areAttributesDirty: boolean;
  7713. /** @hidden */
  7714. _areTexturesDirty: boolean;
  7715. /** @hidden */
  7716. _areFresnelDirty: boolean;
  7717. /** @hidden */
  7718. _areMiscDirty: boolean;
  7719. /** @hidden */
  7720. _areImageProcessingDirty: boolean;
  7721. /** @hidden */
  7722. _normals: boolean;
  7723. /** @hidden */
  7724. _uvs: boolean;
  7725. /** @hidden */
  7726. _needNormals: boolean;
  7727. /** @hidden */
  7728. _needUVs: boolean;
  7729. [id: string]: any;
  7730. /**
  7731. * Specifies if the material needs to be re-calculated
  7732. */
  7733. readonly isDirty: boolean;
  7734. /**
  7735. * Marks the material to indicate that it has been re-calculated
  7736. */
  7737. markAsProcessed(): void;
  7738. /**
  7739. * Marks the material to indicate that it needs to be re-calculated
  7740. */
  7741. markAsUnprocessed(): void;
  7742. /**
  7743. * Marks the material to indicate all of its defines need to be re-calculated
  7744. */
  7745. markAllAsDirty(): void;
  7746. /**
  7747. * Marks the material to indicate that image processing needs to be re-calculated
  7748. */
  7749. markAsImageProcessingDirty(): void;
  7750. /**
  7751. * Marks the material to indicate the lights need to be re-calculated
  7752. * @param disposed Defines whether the light is dirty due to dispose or not
  7753. */
  7754. markAsLightDirty(disposed?: boolean): void;
  7755. /**
  7756. * Marks the attribute state as changed
  7757. */
  7758. markAsAttributesDirty(): void;
  7759. /**
  7760. * Marks the texture state as changed
  7761. */
  7762. markAsTexturesDirty(): void;
  7763. /**
  7764. * Marks the fresnel state as changed
  7765. */
  7766. markAsFresnelDirty(): void;
  7767. /**
  7768. * Marks the misc state as changed
  7769. */
  7770. markAsMiscDirty(): void;
  7771. /**
  7772. * Rebuilds the material defines
  7773. */
  7774. rebuild(): void;
  7775. /**
  7776. * Specifies if two material defines are equal
  7777. * @param other - A material define instance to compare to
  7778. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7779. */
  7780. isEqual(other: MaterialDefines): boolean;
  7781. /**
  7782. * Clones this instance's defines to another instance
  7783. * @param other - material defines to clone values to
  7784. */
  7785. cloneTo(other: MaterialDefines): void;
  7786. /**
  7787. * Resets the material define values
  7788. */
  7789. reset(): void;
  7790. /**
  7791. * Converts the material define values to a string
  7792. * @returns - String of material define information
  7793. */
  7794. toString(): string;
  7795. }
  7796. }
  7797. declare module BABYLON {
  7798. /**
  7799. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7800. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7801. * 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;
  7802. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7803. */
  7804. export class ColorCurves {
  7805. private _dirty;
  7806. private _tempColor;
  7807. private _globalCurve;
  7808. private _highlightsCurve;
  7809. private _midtonesCurve;
  7810. private _shadowsCurve;
  7811. private _positiveCurve;
  7812. private _negativeCurve;
  7813. private _globalHue;
  7814. private _globalDensity;
  7815. private _globalSaturation;
  7816. private _globalExposure;
  7817. /**
  7818. * Gets the global Hue value.
  7819. * 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).
  7820. */
  7821. /**
  7822. * Sets the global Hue value.
  7823. * 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).
  7824. */
  7825. globalHue: number;
  7826. /**
  7827. * Gets the global Density value.
  7828. * 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.
  7829. * Values less than zero provide a filter of opposite hue.
  7830. */
  7831. /**
  7832. * Sets the global Density value.
  7833. * 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.
  7834. * Values less than zero provide a filter of opposite hue.
  7835. */
  7836. globalDensity: number;
  7837. /**
  7838. * Gets the global Saturation value.
  7839. * 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.
  7840. */
  7841. /**
  7842. * Sets the global Saturation value.
  7843. * 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.
  7844. */
  7845. globalSaturation: number;
  7846. /**
  7847. * Gets the global Exposure value.
  7848. * 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.
  7849. */
  7850. /**
  7851. * Sets the global Exposure value.
  7852. * 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.
  7853. */
  7854. globalExposure: number;
  7855. private _highlightsHue;
  7856. private _highlightsDensity;
  7857. private _highlightsSaturation;
  7858. private _highlightsExposure;
  7859. /**
  7860. * Gets the highlights 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 highlights 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. highlightsHue: number;
  7868. /**
  7869. * Gets the highlights 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 highlights 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. highlightsDensity: number;
  7879. /**
  7880. * Gets the highlights 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 highlights 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. highlightsSaturation: number;
  7888. /**
  7889. * Gets the highlights 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 highlights 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. highlightsExposure: number;
  7897. private _midtonesHue;
  7898. private _midtonesDensity;
  7899. private _midtonesSaturation;
  7900. private _midtonesExposure;
  7901. /**
  7902. * Gets the midtones 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 midtones 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. midtonesHue: number;
  7910. /**
  7911. * Gets the midtones 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 midtones 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. midtonesDensity: number;
  7921. /**
  7922. * Gets the midtones 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 midtones 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. midtonesSaturation: number;
  7930. /**
  7931. * Gets the midtones 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 midtones 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. midtonesExposure: number;
  7939. private _shadowsHue;
  7940. private _shadowsDensity;
  7941. private _shadowsSaturation;
  7942. private _shadowsExposure;
  7943. /**
  7944. * Gets the shadows 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 shadows 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. shadowsHue: number;
  7952. /**
  7953. * Gets the shadows 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 shadows 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. shadowsDensity: number;
  7963. /**
  7964. * Gets the shadows 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 shadows 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. shadowsSaturation: number;
  7972. /**
  7973. * Gets the shadows 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 shadows 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. shadowsExposure: number;
  7981. /**
  7982. * Returns the class name
  7983. * @returns The class name
  7984. */
  7985. getClassName(): string;
  7986. /**
  7987. * Binds the color curves to the shader.
  7988. * @param colorCurves The color curve to bind
  7989. * @param effect The effect to bind to
  7990. * @param positiveUniform The positive uniform shader parameter
  7991. * @param neutralUniform The neutral uniform shader parameter
  7992. * @param negativeUniform The negative uniform shader parameter
  7993. */
  7994. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7995. /**
  7996. * Prepare the list of uniforms associated with the ColorCurves effects.
  7997. * @param uniformsList The list of uniforms used in the effect
  7998. */
  7999. static PrepareUniforms(uniformsList: string[]): void;
  8000. /**
  8001. * Returns color grading data based on a hue, density, saturation and exposure value.
  8002. * @param filterHue The hue of the color filter.
  8003. * @param filterDensity The density of the color filter.
  8004. * @param saturation The saturation.
  8005. * @param exposure The exposure.
  8006. * @param result The result data container.
  8007. */
  8008. private getColorGradingDataToRef;
  8009. /**
  8010. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8011. * @param value The input slider value in range [-100,100].
  8012. * @returns Adjusted value.
  8013. */
  8014. private static applyColorGradingSliderNonlinear;
  8015. /**
  8016. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8017. * @param hue The hue (H) input.
  8018. * @param saturation The saturation (S) input.
  8019. * @param brightness The brightness (B) input.
  8020. * @result An RGBA color represented as Vector4.
  8021. */
  8022. private static fromHSBToRef;
  8023. /**
  8024. * Returns a value clamped between min and max
  8025. * @param value The value to clamp
  8026. * @param min The minimum of value
  8027. * @param max The maximum of value
  8028. * @returns The clamped value.
  8029. */
  8030. private static clamp;
  8031. /**
  8032. * Clones the current color curve instance.
  8033. * @return The cloned curves
  8034. */
  8035. clone(): ColorCurves;
  8036. /**
  8037. * Serializes the current color curve instance to a json representation.
  8038. * @return a JSON representation
  8039. */
  8040. serialize(): any;
  8041. /**
  8042. * Parses the color curve from a json representation.
  8043. * @param source the JSON source to parse
  8044. * @return The parsed curves
  8045. */
  8046. static Parse(source: any): ColorCurves;
  8047. }
  8048. }
  8049. declare module BABYLON {
  8050. /**
  8051. * Interface to follow in your material defines to integrate easily the
  8052. * Image proccessing functions.
  8053. * @hidden
  8054. */
  8055. export interface IImageProcessingConfigurationDefines {
  8056. IMAGEPROCESSING: boolean;
  8057. VIGNETTE: boolean;
  8058. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8059. VIGNETTEBLENDMODEOPAQUE: boolean;
  8060. TONEMAPPING: boolean;
  8061. TONEMAPPING_ACES: boolean;
  8062. CONTRAST: boolean;
  8063. EXPOSURE: boolean;
  8064. COLORCURVES: boolean;
  8065. COLORGRADING: boolean;
  8066. COLORGRADING3D: boolean;
  8067. SAMPLER3DGREENDEPTH: boolean;
  8068. SAMPLER3DBGRMAP: boolean;
  8069. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8070. }
  8071. /**
  8072. * @hidden
  8073. */
  8074. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8075. IMAGEPROCESSING: boolean;
  8076. VIGNETTE: boolean;
  8077. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8078. VIGNETTEBLENDMODEOPAQUE: boolean;
  8079. TONEMAPPING: boolean;
  8080. TONEMAPPING_ACES: boolean;
  8081. CONTRAST: boolean;
  8082. COLORCURVES: boolean;
  8083. COLORGRADING: boolean;
  8084. COLORGRADING3D: boolean;
  8085. SAMPLER3DGREENDEPTH: boolean;
  8086. SAMPLER3DBGRMAP: boolean;
  8087. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8088. EXPOSURE: boolean;
  8089. constructor();
  8090. }
  8091. /**
  8092. * This groups together the common properties used for image processing either in direct forward pass
  8093. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8094. * or not.
  8095. */
  8096. export class ImageProcessingConfiguration {
  8097. /**
  8098. * Default tone mapping applied in BabylonJS.
  8099. */
  8100. static readonly TONEMAPPING_STANDARD: number;
  8101. /**
  8102. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8103. * to other engines rendering to increase portability.
  8104. */
  8105. static readonly TONEMAPPING_ACES: number;
  8106. /**
  8107. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8108. */
  8109. colorCurves: Nullable<ColorCurves>;
  8110. private _colorCurvesEnabled;
  8111. /**
  8112. * Gets wether the color curves effect is enabled.
  8113. */
  8114. /**
  8115. * Sets wether the color curves effect is enabled.
  8116. */
  8117. colorCurvesEnabled: boolean;
  8118. private _colorGradingTexture;
  8119. /**
  8120. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8121. */
  8122. /**
  8123. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8124. */
  8125. colorGradingTexture: Nullable<BaseTexture>;
  8126. private _colorGradingEnabled;
  8127. /**
  8128. * Gets wether the color grading effect is enabled.
  8129. */
  8130. /**
  8131. * Sets wether the color grading effect is enabled.
  8132. */
  8133. colorGradingEnabled: boolean;
  8134. private _colorGradingWithGreenDepth;
  8135. /**
  8136. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8137. */
  8138. /**
  8139. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8140. */
  8141. colorGradingWithGreenDepth: boolean;
  8142. private _colorGradingBGR;
  8143. /**
  8144. * Gets wether the color grading texture contains BGR values.
  8145. */
  8146. /**
  8147. * Sets wether the color grading texture contains BGR values.
  8148. */
  8149. colorGradingBGR: boolean;
  8150. /** @hidden */
  8151. _exposure: number;
  8152. /**
  8153. * Gets the Exposure used in the effect.
  8154. */
  8155. /**
  8156. * Sets the Exposure used in the effect.
  8157. */
  8158. exposure: number;
  8159. private _toneMappingEnabled;
  8160. /**
  8161. * Gets wether the tone mapping effect is enabled.
  8162. */
  8163. /**
  8164. * Sets wether the tone mapping effect is enabled.
  8165. */
  8166. toneMappingEnabled: boolean;
  8167. private _toneMappingType;
  8168. /**
  8169. * Gets the type of tone mapping effect.
  8170. */
  8171. /**
  8172. * Sets the type of tone mapping effect used in BabylonJS.
  8173. */
  8174. toneMappingType: number;
  8175. protected _contrast: number;
  8176. /**
  8177. * Gets the contrast used in the effect.
  8178. */
  8179. /**
  8180. * Sets the contrast used in the effect.
  8181. */
  8182. contrast: number;
  8183. /**
  8184. * Vignette stretch size.
  8185. */
  8186. vignetteStretch: number;
  8187. /**
  8188. * Vignette centre X Offset.
  8189. */
  8190. vignetteCentreX: number;
  8191. /**
  8192. * Vignette centre Y Offset.
  8193. */
  8194. vignetteCentreY: number;
  8195. /**
  8196. * Vignette weight or intensity of the vignette effect.
  8197. */
  8198. vignetteWeight: number;
  8199. /**
  8200. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8201. * if vignetteEnabled is set to true.
  8202. */
  8203. vignetteColor: Color4;
  8204. /**
  8205. * Camera field of view used by the Vignette effect.
  8206. */
  8207. vignetteCameraFov: number;
  8208. private _vignetteBlendMode;
  8209. /**
  8210. * Gets the vignette blend mode allowing different kind of effect.
  8211. */
  8212. /**
  8213. * Sets the vignette blend mode allowing different kind of effect.
  8214. */
  8215. vignetteBlendMode: number;
  8216. private _vignetteEnabled;
  8217. /**
  8218. * Gets wether the vignette effect is enabled.
  8219. */
  8220. /**
  8221. * Sets wether the vignette effect is enabled.
  8222. */
  8223. vignetteEnabled: boolean;
  8224. private _applyByPostProcess;
  8225. /**
  8226. * Gets wether the image processing is applied through a post process or not.
  8227. */
  8228. /**
  8229. * Sets wether the image processing is applied through a post process or not.
  8230. */
  8231. applyByPostProcess: boolean;
  8232. private _isEnabled;
  8233. /**
  8234. * Gets wether the image processing is enabled or not.
  8235. */
  8236. /**
  8237. * Sets wether the image processing is enabled or not.
  8238. */
  8239. isEnabled: boolean;
  8240. /**
  8241. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8242. */
  8243. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8244. /**
  8245. * Method called each time the image processing information changes requires to recompile the effect.
  8246. */
  8247. protected _updateParameters(): void;
  8248. /**
  8249. * Gets the current class name.
  8250. * @return "ImageProcessingConfiguration"
  8251. */
  8252. getClassName(): string;
  8253. /**
  8254. * Prepare the list of uniforms associated with the Image Processing effects.
  8255. * @param uniforms The list of uniforms used in the effect
  8256. * @param defines the list of defines currently in use
  8257. */
  8258. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8259. /**
  8260. * Prepare the list of samplers associated with the Image Processing effects.
  8261. * @param samplersList The list of uniforms used in the effect
  8262. * @param defines the list of defines currently in use
  8263. */
  8264. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8265. /**
  8266. * Prepare the list of defines associated to the shader.
  8267. * @param defines the list of defines to complete
  8268. * @param forPostProcess Define if we are currently in post process mode or not
  8269. */
  8270. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8271. /**
  8272. * Returns true if all the image processing information are ready.
  8273. * @returns True if ready, otherwise, false
  8274. */
  8275. isReady(): boolean;
  8276. /**
  8277. * Binds the image processing to the shader.
  8278. * @param effect The effect to bind to
  8279. * @param aspectRatio Define the current aspect ratio of the effect
  8280. */
  8281. bind(effect: Effect, aspectRatio?: number): void;
  8282. /**
  8283. * Clones the current image processing instance.
  8284. * @return The cloned image processing
  8285. */
  8286. clone(): ImageProcessingConfiguration;
  8287. /**
  8288. * Serializes the current image processing instance to a json representation.
  8289. * @return a JSON representation
  8290. */
  8291. serialize(): any;
  8292. /**
  8293. * Parses the image processing from a json representation.
  8294. * @param source the JSON source to parse
  8295. * @return The parsed image processing
  8296. */
  8297. static Parse(source: any): ImageProcessingConfiguration;
  8298. private static _VIGNETTEMODE_MULTIPLY;
  8299. private static _VIGNETTEMODE_OPAQUE;
  8300. /**
  8301. * Used to apply the vignette as a mix with the pixel color.
  8302. */
  8303. static readonly VIGNETTEMODE_MULTIPLY: number;
  8304. /**
  8305. * Used to apply the vignette as a replacement of the pixel color.
  8306. */
  8307. static readonly VIGNETTEMODE_OPAQUE: number;
  8308. }
  8309. }
  8310. declare module BABYLON {
  8311. /** @hidden */
  8312. export var postprocessVertexShader: {
  8313. name: string;
  8314. shader: string;
  8315. };
  8316. }
  8317. declare module BABYLON {
  8318. /** Defines supported spaces */
  8319. export enum Space {
  8320. /** Local (object) space */
  8321. LOCAL = 0,
  8322. /** World space */
  8323. WORLD = 1,
  8324. /** Bone space */
  8325. BONE = 2
  8326. }
  8327. /** Defines the 3 main axes */
  8328. export class Axis {
  8329. /** X axis */
  8330. static X: Vector3;
  8331. /** Y axis */
  8332. static Y: Vector3;
  8333. /** Z axis */
  8334. static Z: Vector3;
  8335. }
  8336. }
  8337. declare module BABYLON {
  8338. /**
  8339. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8340. * This is the base of the follow, arc rotate cameras and Free camera
  8341. * @see http://doc.babylonjs.com/features/cameras
  8342. */
  8343. export class TargetCamera extends Camera {
  8344. private static _RigCamTransformMatrix;
  8345. private static _TargetTransformMatrix;
  8346. private static _TargetFocalPoint;
  8347. /**
  8348. * Define the current direction the camera is moving to
  8349. */
  8350. cameraDirection: Vector3;
  8351. /**
  8352. * Define the current rotation the camera is rotating to
  8353. */
  8354. cameraRotation: Vector2;
  8355. /**
  8356. * When set, the up vector of the camera will be updated by the rotation of the camera
  8357. */
  8358. updateUpVectorFromRotation: boolean;
  8359. private _tmpQuaternion;
  8360. /**
  8361. * Define the current rotation of the camera
  8362. */
  8363. rotation: Vector3;
  8364. /**
  8365. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8366. */
  8367. rotationQuaternion: Quaternion;
  8368. /**
  8369. * Define the current speed of the camera
  8370. */
  8371. speed: number;
  8372. /**
  8373. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8374. * around all axis.
  8375. */
  8376. noRotationConstraint: boolean;
  8377. /**
  8378. * Define the current target of the camera as an object or a position.
  8379. */
  8380. lockedTarget: any;
  8381. /** @hidden */
  8382. _currentTarget: Vector3;
  8383. /** @hidden */
  8384. _initialFocalDistance: number;
  8385. /** @hidden */
  8386. _viewMatrix: Matrix;
  8387. /** @hidden */
  8388. _camMatrix: Matrix;
  8389. /** @hidden */
  8390. _cameraTransformMatrix: Matrix;
  8391. /** @hidden */
  8392. _cameraRotationMatrix: Matrix;
  8393. /** @hidden */
  8394. _referencePoint: Vector3;
  8395. /** @hidden */
  8396. _transformedReferencePoint: Vector3;
  8397. protected _globalCurrentTarget: Vector3;
  8398. protected _globalCurrentUpVector: Vector3;
  8399. /** @hidden */
  8400. _reset: () => void;
  8401. private _defaultUp;
  8402. /**
  8403. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8404. * This is the base of the follow, arc rotate cameras and Free camera
  8405. * @see http://doc.babylonjs.com/features/cameras
  8406. * @param name Defines the name of the camera in the scene
  8407. * @param position Defines the start position of the camera in the scene
  8408. * @param scene Defines the scene the camera belongs to
  8409. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8410. */
  8411. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8412. /**
  8413. * Gets the position in front of the camera at a given distance.
  8414. * @param distance The distance from the camera we want the position to be
  8415. * @returns the position
  8416. */
  8417. getFrontPosition(distance: number): Vector3;
  8418. /** @hidden */
  8419. _getLockedTargetPosition(): Nullable<Vector3>;
  8420. private _storedPosition;
  8421. private _storedRotation;
  8422. private _storedRotationQuaternion;
  8423. /**
  8424. * Store current camera state of the camera (fov, position, rotation, etc..)
  8425. * @returns the camera
  8426. */
  8427. storeState(): Camera;
  8428. /**
  8429. * Restored camera state. You must call storeState() first
  8430. * @returns whether it was successful or not
  8431. * @hidden
  8432. */
  8433. _restoreStateValues(): boolean;
  8434. /** @hidden */
  8435. _initCache(): void;
  8436. /** @hidden */
  8437. _updateCache(ignoreParentClass?: boolean): void;
  8438. /** @hidden */
  8439. _isSynchronizedViewMatrix(): boolean;
  8440. /** @hidden */
  8441. _computeLocalCameraSpeed(): number;
  8442. /**
  8443. * Defines the target the camera should look at.
  8444. * @param target Defines the new target as a Vector or a mesh
  8445. */
  8446. setTarget(target: Vector3): void;
  8447. /**
  8448. * Return the current target position of the camera. This value is expressed in local space.
  8449. * @returns the target position
  8450. */
  8451. getTarget(): Vector3;
  8452. /** @hidden */
  8453. _decideIfNeedsToMove(): boolean;
  8454. /** @hidden */
  8455. _updatePosition(): void;
  8456. /** @hidden */
  8457. _checkInputs(): void;
  8458. protected _updateCameraRotationMatrix(): void;
  8459. /**
  8460. * 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)
  8461. * @returns the current camera
  8462. */
  8463. private _rotateUpVectorWithCameraRotationMatrix;
  8464. private _cachedRotationZ;
  8465. private _cachedQuaternionRotationZ;
  8466. /** @hidden */
  8467. _getViewMatrix(): Matrix;
  8468. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8469. /**
  8470. * @hidden
  8471. */
  8472. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8473. /**
  8474. * @hidden
  8475. */
  8476. _updateRigCameras(): void;
  8477. private _getRigCamPositionAndTarget;
  8478. /**
  8479. * Gets the current object class name.
  8480. * @return the class name
  8481. */
  8482. getClassName(): string;
  8483. }
  8484. }
  8485. declare module BABYLON {
  8486. /**
  8487. * Gather the list of keyboard event types as constants.
  8488. */
  8489. export class KeyboardEventTypes {
  8490. /**
  8491. * The keydown event is fired when a key becomes active (pressed).
  8492. */
  8493. static readonly KEYDOWN: number;
  8494. /**
  8495. * The keyup event is fired when a key has been released.
  8496. */
  8497. static readonly KEYUP: number;
  8498. }
  8499. /**
  8500. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8501. */
  8502. export class KeyboardInfo {
  8503. /**
  8504. * Defines the type of event (KeyboardEventTypes)
  8505. */
  8506. type: number;
  8507. /**
  8508. * Defines the related dom event
  8509. */
  8510. event: KeyboardEvent;
  8511. /**
  8512. * Instantiates a new keyboard info.
  8513. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8514. * @param type Defines the type of event (KeyboardEventTypes)
  8515. * @param event Defines the related dom event
  8516. */
  8517. constructor(
  8518. /**
  8519. * Defines the type of event (KeyboardEventTypes)
  8520. */
  8521. type: number,
  8522. /**
  8523. * Defines the related dom event
  8524. */
  8525. event: KeyboardEvent);
  8526. }
  8527. /**
  8528. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8529. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8530. */
  8531. export class KeyboardInfoPre extends KeyboardInfo {
  8532. /**
  8533. * Defines the type of event (KeyboardEventTypes)
  8534. */
  8535. type: number;
  8536. /**
  8537. * Defines the related dom event
  8538. */
  8539. event: KeyboardEvent;
  8540. /**
  8541. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8542. */
  8543. skipOnPointerObservable: boolean;
  8544. /**
  8545. * Instantiates a new keyboard pre info.
  8546. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8547. * @param type Defines the type of event (KeyboardEventTypes)
  8548. * @param event Defines the related dom event
  8549. */
  8550. constructor(
  8551. /**
  8552. * Defines the type of event (KeyboardEventTypes)
  8553. */
  8554. type: number,
  8555. /**
  8556. * Defines the related dom event
  8557. */
  8558. event: KeyboardEvent);
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Manage the keyboard inputs to control the movement of a free camera.
  8564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8565. */
  8566. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8567. /**
  8568. * Defines the camera the input is attached to.
  8569. */
  8570. camera: FreeCamera;
  8571. /**
  8572. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8573. */
  8574. keysUp: number[];
  8575. /**
  8576. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8577. */
  8578. keysDown: number[];
  8579. /**
  8580. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8581. */
  8582. keysLeft: number[];
  8583. /**
  8584. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8585. */
  8586. keysRight: number[];
  8587. private _keys;
  8588. private _onCanvasBlurObserver;
  8589. private _onKeyboardObserver;
  8590. private _engine;
  8591. private _scene;
  8592. /**
  8593. * Attach the input controls to a specific dom element to get the input from.
  8594. * @param element Defines the element the controls should be listened from
  8595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8596. */
  8597. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8598. /**
  8599. * Detach the current controls from the specified dom element.
  8600. * @param element Defines the element to stop listening the inputs from
  8601. */
  8602. detachControl(element: Nullable<HTMLElement>): void;
  8603. /**
  8604. * Update the current camera state depending on the inputs that have been used this frame.
  8605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8606. */
  8607. checkInputs(): void;
  8608. /**
  8609. * Gets the class name of the current intput.
  8610. * @returns the class name
  8611. */
  8612. getClassName(): string;
  8613. /** @hidden */
  8614. _onLostFocus(): void;
  8615. /**
  8616. * Get the friendly name associated with the input class.
  8617. * @returns the input friendly name
  8618. */
  8619. getSimpleName(): string;
  8620. }
  8621. }
  8622. declare module BABYLON {
  8623. /**
  8624. * Interface describing all the common properties and methods a shadow light needs to implement.
  8625. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8626. * as well as binding the different shadow properties to the effects.
  8627. */
  8628. export interface IShadowLight extends Light {
  8629. /**
  8630. * The light id in the scene (used in scene.findLighById for instance)
  8631. */
  8632. id: string;
  8633. /**
  8634. * The position the shdow will be casted from.
  8635. */
  8636. position: Vector3;
  8637. /**
  8638. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8639. */
  8640. direction: Vector3;
  8641. /**
  8642. * The transformed position. Position of the light in world space taking parenting in account.
  8643. */
  8644. transformedPosition: Vector3;
  8645. /**
  8646. * The transformed direction. Direction of the light in world space taking parenting in account.
  8647. */
  8648. transformedDirection: Vector3;
  8649. /**
  8650. * The friendly name of the light in the scene.
  8651. */
  8652. name: string;
  8653. /**
  8654. * Defines the shadow projection clipping minimum z value.
  8655. */
  8656. shadowMinZ: number;
  8657. /**
  8658. * Defines the shadow projection clipping maximum z value.
  8659. */
  8660. shadowMaxZ: number;
  8661. /**
  8662. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8663. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8664. */
  8665. computeTransformedInformation(): boolean;
  8666. /**
  8667. * Gets the scene the light belongs to.
  8668. * @returns The scene
  8669. */
  8670. getScene(): Scene;
  8671. /**
  8672. * Callback defining a custom Projection Matrix Builder.
  8673. * This can be used to override the default projection matrix computation.
  8674. */
  8675. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8676. /**
  8677. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8678. * @param matrix The materix to updated with the projection information
  8679. * @param viewMatrix The transform matrix of the light
  8680. * @param renderList The list of mesh to render in the map
  8681. * @returns The current light
  8682. */
  8683. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8684. /**
  8685. * Gets the current depth scale used in ESM.
  8686. * @returns The scale
  8687. */
  8688. getDepthScale(): number;
  8689. /**
  8690. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8691. * @returns true if a cube texture needs to be use
  8692. */
  8693. needCube(): boolean;
  8694. /**
  8695. * Detects if the projection matrix requires to be recomputed this frame.
  8696. * @returns true if it requires to be recomputed otherwise, false.
  8697. */
  8698. needProjectionMatrixCompute(): boolean;
  8699. /**
  8700. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8701. */
  8702. forceProjectionMatrixCompute(): void;
  8703. /**
  8704. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8705. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8706. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8707. */
  8708. getShadowDirection(faceIndex?: number): Vector3;
  8709. /**
  8710. * Gets the minZ used for shadow according to both the scene and the light.
  8711. * @param activeCamera The camera we are returning the min for
  8712. * @returns the depth min z
  8713. */
  8714. getDepthMinZ(activeCamera: Camera): number;
  8715. /**
  8716. * Gets the maxZ used for shadow according to both the scene and the light.
  8717. * @param activeCamera The camera we are returning the max for
  8718. * @returns the depth max z
  8719. */
  8720. getDepthMaxZ(activeCamera: Camera): number;
  8721. }
  8722. /**
  8723. * Base implementation IShadowLight
  8724. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8725. */
  8726. export abstract class ShadowLight extends Light implements IShadowLight {
  8727. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8728. protected _position: Vector3;
  8729. protected _setPosition(value: Vector3): void;
  8730. /**
  8731. * Sets the position the shadow will be casted from. Also use as the light position for both
  8732. * point and spot lights.
  8733. */
  8734. /**
  8735. * Sets the position the shadow will be casted from. Also use as the light position for both
  8736. * point and spot lights.
  8737. */
  8738. position: Vector3;
  8739. protected _direction: Vector3;
  8740. protected _setDirection(value: Vector3): void;
  8741. /**
  8742. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8743. * Also use as the light direction on spot and directional lights.
  8744. */
  8745. /**
  8746. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8747. * Also use as the light direction on spot and directional lights.
  8748. */
  8749. direction: Vector3;
  8750. private _shadowMinZ;
  8751. /**
  8752. * Gets the shadow projection clipping minimum z value.
  8753. */
  8754. /**
  8755. * Sets the shadow projection clipping minimum z value.
  8756. */
  8757. shadowMinZ: number;
  8758. private _shadowMaxZ;
  8759. /**
  8760. * Sets the shadow projection clipping maximum z value.
  8761. */
  8762. /**
  8763. * Gets the shadow projection clipping maximum z value.
  8764. */
  8765. shadowMaxZ: number;
  8766. /**
  8767. * Callback defining a custom Projection Matrix Builder.
  8768. * This can be used to override the default projection matrix computation.
  8769. */
  8770. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8771. /**
  8772. * The transformed position. Position of the light in world space taking parenting in account.
  8773. */
  8774. transformedPosition: Vector3;
  8775. /**
  8776. * The transformed direction. Direction of the light in world space taking parenting in account.
  8777. */
  8778. transformedDirection: Vector3;
  8779. private _needProjectionMatrixCompute;
  8780. /**
  8781. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8782. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8783. */
  8784. computeTransformedInformation(): boolean;
  8785. /**
  8786. * Return the depth scale used for the shadow map.
  8787. * @returns the depth scale.
  8788. */
  8789. getDepthScale(): number;
  8790. /**
  8791. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8792. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8793. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8794. */
  8795. getShadowDirection(faceIndex?: number): Vector3;
  8796. /**
  8797. * Returns the ShadowLight absolute position in the World.
  8798. * @returns the position vector in world space
  8799. */
  8800. getAbsolutePosition(): Vector3;
  8801. /**
  8802. * Sets the ShadowLight direction toward the passed target.
  8803. * @param target The point to target in local space
  8804. * @returns the updated ShadowLight direction
  8805. */
  8806. setDirectionToTarget(target: Vector3): Vector3;
  8807. /**
  8808. * Returns the light rotation in euler definition.
  8809. * @returns the x y z rotation in local space.
  8810. */
  8811. getRotation(): Vector3;
  8812. /**
  8813. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8814. * @returns true if a cube texture needs to be use
  8815. */
  8816. needCube(): boolean;
  8817. /**
  8818. * Detects if the projection matrix requires to be recomputed this frame.
  8819. * @returns true if it requires to be recomputed otherwise, false.
  8820. */
  8821. needProjectionMatrixCompute(): boolean;
  8822. /**
  8823. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8824. */
  8825. forceProjectionMatrixCompute(): void;
  8826. /** @hidden */
  8827. _initCache(): void;
  8828. /** @hidden */
  8829. _isSynchronized(): boolean;
  8830. /**
  8831. * Computes the world matrix of the node
  8832. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8833. * @returns the world matrix
  8834. */
  8835. computeWorldMatrix(force?: boolean): Matrix;
  8836. /**
  8837. * Gets the minZ used for shadow according to both the scene and the light.
  8838. * @param activeCamera The camera we are returning the min for
  8839. * @returns the depth min z
  8840. */
  8841. getDepthMinZ(activeCamera: Camera): number;
  8842. /**
  8843. * Gets the maxZ used for shadow according to both the scene and the light.
  8844. * @param activeCamera The camera we are returning the max for
  8845. * @returns the depth max z
  8846. */
  8847. getDepthMaxZ(activeCamera: Camera): number;
  8848. /**
  8849. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8850. * @param matrix The materix to updated with the projection information
  8851. * @param viewMatrix The transform matrix of the light
  8852. * @param renderList The list of mesh to render in the map
  8853. * @returns The current light
  8854. */
  8855. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8856. }
  8857. }
  8858. declare module BABYLON {
  8859. /**
  8860. * "Static Class" containing the most commonly used helper while dealing with material for
  8861. * rendering purpose.
  8862. *
  8863. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8864. *
  8865. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8866. */
  8867. export class MaterialHelper {
  8868. /**
  8869. * Bind the current view position to an effect.
  8870. * @param effect The effect to be bound
  8871. * @param scene The scene the eyes position is used from
  8872. */
  8873. static BindEyePosition(effect: Effect, scene: Scene): void;
  8874. /**
  8875. * Helps preparing the defines values about the UVs in used in the effect.
  8876. * UVs are shared as much as we can accross channels in the shaders.
  8877. * @param texture The texture we are preparing the UVs for
  8878. * @param defines The defines to update
  8879. * @param key The channel key "diffuse", "specular"... used in the shader
  8880. */
  8881. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8882. /**
  8883. * Binds a texture matrix value to its corrsponding uniform
  8884. * @param texture The texture to bind the matrix for
  8885. * @param uniformBuffer The uniform buffer receivin the data
  8886. * @param key The channel key "diffuse", "specular"... used in the shader
  8887. */
  8888. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8889. /**
  8890. * Gets the current status of the fog (should it be enabled?)
  8891. * @param mesh defines the mesh to evaluate for fog support
  8892. * @param scene defines the hosting scene
  8893. * @returns true if fog must be enabled
  8894. */
  8895. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8896. /**
  8897. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8898. * @param mesh defines the current mesh
  8899. * @param scene defines the current scene
  8900. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8901. * @param pointsCloud defines if point cloud rendering has to be turned on
  8902. * @param fogEnabled defines if fog has to be turned on
  8903. * @param alphaTest defines if alpha testing has to be turned on
  8904. * @param defines defines the current list of defines
  8905. */
  8906. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8907. /**
  8908. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8909. * @param scene defines the current scene
  8910. * @param engine defines the current engine
  8911. * @param defines specifies the list of active defines
  8912. * @param useInstances defines if instances have to be turned on
  8913. * @param useClipPlane defines if clip plane have to be turned on
  8914. */
  8915. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8916. /**
  8917. * Prepares the defines for bones
  8918. * @param mesh The mesh containing the geometry data we will draw
  8919. * @param defines The defines to update
  8920. */
  8921. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8922. /**
  8923. * Prepares the defines for morph targets
  8924. * @param mesh The mesh containing the geometry data we will draw
  8925. * @param defines The defines to update
  8926. */
  8927. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8928. /**
  8929. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8930. * @param mesh The mesh containing the geometry data we will draw
  8931. * @param defines The defines to update
  8932. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8933. * @param useBones Precise whether bones should be used or not (override mesh info)
  8934. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8935. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8936. * @returns false if defines are considered not dirty and have not been checked
  8937. */
  8938. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8939. /**
  8940. * Prepares the defines related to multiview
  8941. * @param scene The scene we are intending to draw
  8942. * @param defines The defines to update
  8943. */
  8944. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8945. /**
  8946. * Prepares the defines related to the light information passed in parameter
  8947. * @param scene The scene we are intending to draw
  8948. * @param mesh The mesh the effect is compiling for
  8949. * @param light The light the effect is compiling for
  8950. * @param lightIndex The index of the light
  8951. * @param defines The defines to update
  8952. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8953. * @param state Defines the current state regarding what is needed (normals, etc...)
  8954. */
  8955. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8956. needNormals: boolean;
  8957. needRebuild: boolean;
  8958. shadowEnabled: boolean;
  8959. specularEnabled: boolean;
  8960. lightmapMode: boolean;
  8961. }): void;
  8962. /**
  8963. * Prepares the defines related to the light information passed in parameter
  8964. * @param scene The scene we are intending to draw
  8965. * @param mesh The mesh the effect is compiling for
  8966. * @param defines The defines to update
  8967. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8968. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8969. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8970. * @returns true if normals will be required for the rest of the effect
  8971. */
  8972. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8973. /**
  8974. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8975. * @param lightIndex defines the light index
  8976. * @param uniformsList The uniform list
  8977. * @param samplersList The sampler list
  8978. * @param projectedLightTexture defines if projected texture must be used
  8979. * @param uniformBuffersList defines an optional list of uniform buffers
  8980. */
  8981. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8982. /**
  8983. * Prepares the uniforms and samplers list to be used in the effect
  8984. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8985. * @param samplersList The sampler list
  8986. * @param defines The defines helping in the list generation
  8987. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8988. */
  8989. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8990. /**
  8991. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8992. * @param defines The defines to update while falling back
  8993. * @param fallbacks The authorized effect fallbacks
  8994. * @param maxSimultaneousLights The maximum number of lights allowed
  8995. * @param rank the current rank of the Effect
  8996. * @returns The newly affected rank
  8997. */
  8998. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8999. private static _TmpMorphInfluencers;
  9000. /**
  9001. * Prepares the list of attributes required for morph targets according to the effect defines.
  9002. * @param attribs The current list of supported attribs
  9003. * @param mesh The mesh to prepare the morph targets attributes for
  9004. * @param influencers The number of influencers
  9005. */
  9006. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9007. /**
  9008. * Prepares the list of attributes required for morph targets according to the effect defines.
  9009. * @param attribs The current list of supported attribs
  9010. * @param mesh The mesh to prepare the morph targets attributes for
  9011. * @param defines The current Defines of the effect
  9012. */
  9013. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9014. /**
  9015. * Prepares the list of attributes required for bones according to the effect defines.
  9016. * @param attribs The current list of supported attribs
  9017. * @param mesh The mesh to prepare the bones attributes for
  9018. * @param defines The current Defines of the effect
  9019. * @param fallbacks The current efffect fallback strategy
  9020. */
  9021. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9022. /**
  9023. * Check and prepare the list of attributes required for instances according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param defines The current MaterialDefines of the effect
  9026. */
  9027. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9028. /**
  9029. * Add the list of attributes required for instances to the attribs array.
  9030. * @param attribs The current list of supported attribs
  9031. */
  9032. static PushAttributesForInstances(attribs: string[]): void;
  9033. /**
  9034. * Binds the light shadow information to the effect for the given mesh.
  9035. * @param light The light containing the generator
  9036. * @param scene The scene the lights belongs to
  9037. * @param mesh The mesh we are binding the information to render
  9038. * @param lightIndex The light index in the effect used to render the mesh
  9039. * @param effect The effect we are binding the data to
  9040. */
  9041. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9042. /**
  9043. * Binds the light information to the effect.
  9044. * @param light The light containing the generator
  9045. * @param effect The effect we are binding the data to
  9046. * @param lightIndex The light index in the effect used to render
  9047. */
  9048. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9049. /**
  9050. * Binds the lights information from the scene to the effect for the given mesh.
  9051. * @param light Light to bind
  9052. * @param lightIndex Light index
  9053. * @param scene The scene where the light belongs to
  9054. * @param mesh The mesh we are binding the information to render
  9055. * @param effect The effect we are binding the data to
  9056. * @param useSpecular Defines if specular is supported
  9057. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9058. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9059. */
  9060. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9061. /**
  9062. * Binds the lights information from the scene to the effect for the given mesh.
  9063. * @param scene The scene the lights belongs to
  9064. * @param mesh The mesh we are binding the information to render
  9065. * @param effect The effect we are binding the data to
  9066. * @param defines The generated defines for the effect
  9067. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9068. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9069. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9070. */
  9071. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9072. private static _tempFogColor;
  9073. /**
  9074. * Binds the fog information from the scene to the effect for the given mesh.
  9075. * @param scene The scene the lights belongs to
  9076. * @param mesh The mesh we are binding the information to render
  9077. * @param effect The effect we are binding the data to
  9078. * @param linearSpace Defines if the fog effect is applied in linear space
  9079. */
  9080. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9081. /**
  9082. * Binds the bones information from the mesh to the effect.
  9083. * @param mesh The mesh we are binding the information to render
  9084. * @param effect The effect we are binding the data to
  9085. */
  9086. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9087. /**
  9088. * Binds the morph targets information from the mesh to the effect.
  9089. * @param abstractMesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9093. /**
  9094. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9095. * @param defines The generated defines used in the effect
  9096. * @param effect The effect we are binding the data to
  9097. * @param scene The scene we are willing to render with logarithmic scale for
  9098. */
  9099. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9100. /**
  9101. * Binds the clip plane information from the scene to the effect.
  9102. * @param scene The scene the clip plane information are extracted from
  9103. * @param effect The effect we are binding the data to
  9104. */
  9105. static BindClipPlane(effect: Effect, scene: Scene): void;
  9106. }
  9107. }
  9108. declare module BABYLON {
  9109. /** @hidden */
  9110. export var packingFunctions: {
  9111. name: string;
  9112. shader: string;
  9113. };
  9114. }
  9115. declare module BABYLON {
  9116. /** @hidden */
  9117. export var shadowMapPixelShader: {
  9118. name: string;
  9119. shader: string;
  9120. };
  9121. }
  9122. declare module BABYLON {
  9123. /** @hidden */
  9124. export var bonesDeclaration: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module BABYLON {
  9130. /** @hidden */
  9131. export var morphTargetsVertexGlobalDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module BABYLON {
  9137. /** @hidden */
  9138. export var morphTargetsVertexDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module BABYLON {
  9144. /** @hidden */
  9145. export var instancesDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module BABYLON {
  9151. /** @hidden */
  9152. export var helperFunctions: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module BABYLON {
  9158. /** @hidden */
  9159. export var morphTargetsVertex: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module BABYLON {
  9165. /** @hidden */
  9166. export var instancesVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module BABYLON {
  9172. /** @hidden */
  9173. export var bonesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module BABYLON {
  9179. /** @hidden */
  9180. export var shadowMapVertexShader: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module BABYLON {
  9186. /** @hidden */
  9187. export var depthBoxBlurPixelShader: {
  9188. name: string;
  9189. shader: string;
  9190. };
  9191. }
  9192. declare module BABYLON {
  9193. /**
  9194. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9195. */
  9196. export interface ICustomShaderOptions {
  9197. /**
  9198. * Gets or sets the custom shader name to use
  9199. */
  9200. shaderName: string;
  9201. /**
  9202. * The list of attribute names used in the shader
  9203. */
  9204. attributes?: string[];
  9205. /**
  9206. * The list of unifrom names used in the shader
  9207. */
  9208. uniforms?: string[];
  9209. /**
  9210. * The list of sampler names used in the shader
  9211. */
  9212. samplers?: string[];
  9213. /**
  9214. * The list of defines used in the shader
  9215. */
  9216. defines?: string[];
  9217. }
  9218. /**
  9219. * Interface to implement to create a shadow generator compatible with BJS.
  9220. */
  9221. export interface IShadowGenerator {
  9222. /**
  9223. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9224. * @returns The render target texture if present otherwise, null
  9225. */
  9226. getShadowMap(): Nullable<RenderTargetTexture>;
  9227. /**
  9228. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9229. * @returns The render target texture if the shadow map is present otherwise, null
  9230. */
  9231. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9232. /**
  9233. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9234. * @param subMesh The submesh we want to render in the shadow map
  9235. * @param useInstances Defines wether will draw in the map using instances
  9236. * @returns true if ready otherwise, false
  9237. */
  9238. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9239. /**
  9240. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9241. * @param defines Defines of the material we want to update
  9242. * @param lightIndex Index of the light in the enabled light list of the material
  9243. */
  9244. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9245. /**
  9246. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9247. * defined in the generator but impacting the effect).
  9248. * It implies the unifroms available on the materials are the standard BJS ones.
  9249. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9250. * @param effect The effect we are binfing the information for
  9251. */
  9252. bindShadowLight(lightIndex: string, effect: Effect): void;
  9253. /**
  9254. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9255. * (eq to shadow prjection matrix * light transform matrix)
  9256. * @returns The transform matrix used to create the shadow map
  9257. */
  9258. getTransformMatrix(): Matrix;
  9259. /**
  9260. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9261. * Cube and 2D textures for instance.
  9262. */
  9263. recreateShadowMap(): void;
  9264. /**
  9265. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9266. * @param onCompiled Callback triggered at the and of the effects compilation
  9267. * @param options Sets of optional options forcing the compilation with different modes
  9268. */
  9269. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9270. useInstances: boolean;
  9271. }>): void;
  9272. /**
  9273. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9274. * @param options Sets of optional options forcing the compilation with different modes
  9275. * @returns A promise that resolves when the compilation completes
  9276. */
  9277. forceCompilationAsync(options?: Partial<{
  9278. useInstances: boolean;
  9279. }>): Promise<void>;
  9280. /**
  9281. * Serializes the shadow generator setup to a json object.
  9282. * @returns The serialized JSON object
  9283. */
  9284. serialize(): any;
  9285. /**
  9286. * Disposes the Shadow map and related Textures and effects.
  9287. */
  9288. dispose(): void;
  9289. }
  9290. /**
  9291. * Default implementation IShadowGenerator.
  9292. * This is the main object responsible of generating shadows in the framework.
  9293. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9294. */
  9295. export class ShadowGenerator implements IShadowGenerator {
  9296. /**
  9297. * Shadow generator mode None: no filtering applied.
  9298. */
  9299. static readonly FILTER_NONE: number;
  9300. /**
  9301. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9302. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9303. */
  9304. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9305. /**
  9306. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9307. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9308. */
  9309. static readonly FILTER_POISSONSAMPLING: number;
  9310. /**
  9311. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9312. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9313. */
  9314. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9315. /**
  9316. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9317. * edge artifacts on steep falloff.
  9318. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9319. */
  9320. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9321. /**
  9322. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9323. * edge artifacts on steep falloff.
  9324. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9325. */
  9326. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9327. /**
  9328. * Shadow generator mode PCF: Percentage Closer Filtering
  9329. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9330. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9331. */
  9332. static readonly FILTER_PCF: number;
  9333. /**
  9334. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9335. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9336. * Contact Hardening
  9337. */
  9338. static readonly FILTER_PCSS: number;
  9339. /**
  9340. * Reserved for PCF and PCSS
  9341. * Highest Quality.
  9342. *
  9343. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9344. *
  9345. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9346. */
  9347. static readonly QUALITY_HIGH: number;
  9348. /**
  9349. * Reserved for PCF and PCSS
  9350. * Good tradeoff for quality/perf cross devices
  9351. *
  9352. * Execute PCF on a 3*3 kernel.
  9353. *
  9354. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9355. */
  9356. static readonly QUALITY_MEDIUM: number;
  9357. /**
  9358. * Reserved for PCF and PCSS
  9359. * The lowest quality but the fastest.
  9360. *
  9361. * Execute PCF on a 1*1 kernel.
  9362. *
  9363. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9364. */
  9365. static readonly QUALITY_LOW: number;
  9366. /** Gets or sets the custom shader name to use */
  9367. customShaderOptions: ICustomShaderOptions;
  9368. /**
  9369. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9370. */
  9371. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9372. /**
  9373. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9374. */
  9375. onAfterShadowMapRenderObservable: Observable<Effect>;
  9376. /**
  9377. * Observable triggered before a mesh is rendered in the shadow map.
  9378. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9379. */
  9380. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9381. /**
  9382. * Observable triggered after a mesh is rendered in the shadow map.
  9383. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9384. */
  9385. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9386. private _bias;
  9387. /**
  9388. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9389. */
  9390. /**
  9391. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9392. */
  9393. bias: number;
  9394. private _normalBias;
  9395. /**
  9396. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9397. */
  9398. /**
  9399. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9400. */
  9401. normalBias: number;
  9402. private _blurBoxOffset;
  9403. /**
  9404. * Gets the blur box offset: offset applied during the blur pass.
  9405. * Only useful if useKernelBlur = false
  9406. */
  9407. /**
  9408. * Sets the blur box offset: offset applied during the blur pass.
  9409. * Only useful if useKernelBlur = false
  9410. */
  9411. blurBoxOffset: number;
  9412. private _blurScale;
  9413. /**
  9414. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9415. * 2 means half of the size.
  9416. */
  9417. /**
  9418. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9419. * 2 means half of the size.
  9420. */
  9421. blurScale: number;
  9422. private _blurKernel;
  9423. /**
  9424. * Gets the blur kernel: kernel size of the blur pass.
  9425. * Only useful if useKernelBlur = true
  9426. */
  9427. /**
  9428. * Sets the blur kernel: kernel size of the blur pass.
  9429. * Only useful if useKernelBlur = true
  9430. */
  9431. blurKernel: number;
  9432. private _useKernelBlur;
  9433. /**
  9434. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9435. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9436. */
  9437. /**
  9438. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9439. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9440. */
  9441. useKernelBlur: boolean;
  9442. private _depthScale;
  9443. /**
  9444. * Gets the depth scale used in ESM mode.
  9445. */
  9446. /**
  9447. * Sets the depth scale used in ESM mode.
  9448. * This can override the scale stored on the light.
  9449. */
  9450. depthScale: number;
  9451. private _filter;
  9452. /**
  9453. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9454. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9455. */
  9456. /**
  9457. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9458. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9459. */
  9460. filter: number;
  9461. /**
  9462. * Gets if the current filter is set to Poisson Sampling.
  9463. */
  9464. /**
  9465. * Sets the current filter to Poisson Sampling.
  9466. */
  9467. usePoissonSampling: boolean;
  9468. /**
  9469. * Gets if the current filter is set to ESM.
  9470. */
  9471. /**
  9472. * Sets the current filter is to ESM.
  9473. */
  9474. useExponentialShadowMap: boolean;
  9475. /**
  9476. * Gets if the current filter is set to filtered ESM.
  9477. */
  9478. /**
  9479. * Gets if the current filter is set to filtered ESM.
  9480. */
  9481. useBlurExponentialShadowMap: boolean;
  9482. /**
  9483. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9484. * exponential to prevent steep falloff artifacts).
  9485. */
  9486. /**
  9487. * Sets the current filter to "close ESM" (using the inverse of the
  9488. * exponential to prevent steep falloff artifacts).
  9489. */
  9490. useCloseExponentialShadowMap: boolean;
  9491. /**
  9492. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9493. * exponential to prevent steep falloff artifacts).
  9494. */
  9495. /**
  9496. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9497. * exponential to prevent steep falloff artifacts).
  9498. */
  9499. useBlurCloseExponentialShadowMap: boolean;
  9500. /**
  9501. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9502. */
  9503. /**
  9504. * Sets the current filter to "PCF" (percentage closer filtering).
  9505. */
  9506. usePercentageCloserFiltering: boolean;
  9507. private _filteringQuality;
  9508. /**
  9509. * Gets the PCF or PCSS Quality.
  9510. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9511. */
  9512. /**
  9513. * Sets the PCF or PCSS Quality.
  9514. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9515. */
  9516. filteringQuality: number;
  9517. /**
  9518. * Gets if the current filter is set to "PCSS" (contact hardening).
  9519. */
  9520. /**
  9521. * Sets the current filter to "PCSS" (contact hardening).
  9522. */
  9523. useContactHardeningShadow: boolean;
  9524. private _contactHardeningLightSizeUVRatio;
  9525. /**
  9526. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9527. * Using a ratio helps keeping shape stability independently of the map size.
  9528. *
  9529. * It does not account for the light projection as it was having too much
  9530. * instability during the light setup or during light position changes.
  9531. *
  9532. * Only valid if useContactHardeningShadow is true.
  9533. */
  9534. /**
  9535. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9536. * Using a ratio helps keeping shape stability independently of the map size.
  9537. *
  9538. * It does not account for the light projection as it was having too much
  9539. * instability during the light setup or during light position changes.
  9540. *
  9541. * Only valid if useContactHardeningShadow is true.
  9542. */
  9543. contactHardeningLightSizeUVRatio: number;
  9544. private _darkness;
  9545. /** Gets or sets the actual darkness of a shadow */
  9546. darkness: number;
  9547. /**
  9548. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9549. * 0 means strongest and 1 would means no shadow.
  9550. * @returns the darkness.
  9551. */
  9552. getDarkness(): number;
  9553. /**
  9554. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9555. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9556. * @returns the shadow generator allowing fluent coding.
  9557. */
  9558. setDarkness(darkness: number): ShadowGenerator;
  9559. private _transparencyShadow;
  9560. /** Gets or sets the ability to have transparent shadow */
  9561. transparencyShadow: boolean;
  9562. /**
  9563. * Sets the ability to have transparent shadow (boolean).
  9564. * @param transparent True if transparent else False
  9565. * @returns the shadow generator allowing fluent coding
  9566. */
  9567. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9568. private _shadowMap;
  9569. private _shadowMap2;
  9570. /**
  9571. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9572. * @returns The render target texture if present otherwise, null
  9573. */
  9574. getShadowMap(): Nullable<RenderTargetTexture>;
  9575. /**
  9576. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9577. * @returns The render target texture if the shadow map is present otherwise, null
  9578. */
  9579. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9580. /**
  9581. * Gets the class name of that object
  9582. * @returns "ShadowGenerator"
  9583. */
  9584. getClassName(): string;
  9585. /**
  9586. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9587. * @param mesh Mesh to add
  9588. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9589. * @returns the Shadow Generator itself
  9590. */
  9591. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9592. /**
  9593. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9594. * @param mesh Mesh to remove
  9595. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9596. * @returns the Shadow Generator itself
  9597. */
  9598. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9599. /**
  9600. * Controls the extent to which the shadows fade out at the edge of the frustum
  9601. * Used only by directionals and spots
  9602. */
  9603. frustumEdgeFalloff: number;
  9604. private _light;
  9605. /**
  9606. * Returns the associated light object.
  9607. * @returns the light generating the shadow
  9608. */
  9609. getLight(): IShadowLight;
  9610. /**
  9611. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9612. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9613. * It might on the other hand introduce peter panning.
  9614. */
  9615. forceBackFacesOnly: boolean;
  9616. private _scene;
  9617. private _lightDirection;
  9618. private _effect;
  9619. private _viewMatrix;
  9620. private _projectionMatrix;
  9621. private _transformMatrix;
  9622. private _cachedPosition;
  9623. private _cachedDirection;
  9624. private _cachedDefines;
  9625. private _currentRenderID;
  9626. private _boxBlurPostprocess;
  9627. private _kernelBlurXPostprocess;
  9628. private _kernelBlurYPostprocess;
  9629. private _blurPostProcesses;
  9630. private _mapSize;
  9631. private _currentFaceIndex;
  9632. private _currentFaceIndexCache;
  9633. private _textureType;
  9634. private _defaultTextureMatrix;
  9635. /** @hidden */
  9636. static _SceneComponentInitialization: (scene: Scene) => void;
  9637. /**
  9638. * Creates a ShadowGenerator object.
  9639. * A ShadowGenerator is the required tool to use the shadows.
  9640. * Each light casting shadows needs to use its own ShadowGenerator.
  9641. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9642. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9643. * @param light The light object generating the shadows.
  9644. * @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.
  9645. */
  9646. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9647. private _initializeGenerator;
  9648. private _initializeShadowMap;
  9649. private _initializeBlurRTTAndPostProcesses;
  9650. private _renderForShadowMap;
  9651. private _renderSubMeshForShadowMap;
  9652. private _applyFilterValues;
  9653. /**
  9654. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9655. * @param onCompiled Callback triggered at the and of the effects compilation
  9656. * @param options Sets of optional options forcing the compilation with different modes
  9657. */
  9658. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9659. useInstances: boolean;
  9660. }>): void;
  9661. /**
  9662. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9663. * @param options Sets of optional options forcing the compilation with different modes
  9664. * @returns A promise that resolves when the compilation completes
  9665. */
  9666. forceCompilationAsync(options?: Partial<{
  9667. useInstances: boolean;
  9668. }>): Promise<void>;
  9669. /**
  9670. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9671. * @param subMesh The submesh we want to render in the shadow map
  9672. * @param useInstances Defines wether will draw in the map using instances
  9673. * @returns true if ready otherwise, false
  9674. */
  9675. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9676. /**
  9677. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9678. * @param defines Defines of the material we want to update
  9679. * @param lightIndex Index of the light in the enabled light list of the material
  9680. */
  9681. prepareDefines(defines: any, lightIndex: number): void;
  9682. /**
  9683. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9684. * defined in the generator but impacting the effect).
  9685. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9686. * @param effect The effect we are binfing the information for
  9687. */
  9688. bindShadowLight(lightIndex: string, effect: Effect): void;
  9689. /**
  9690. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9691. * (eq to shadow prjection matrix * light transform matrix)
  9692. * @returns The transform matrix used to create the shadow map
  9693. */
  9694. getTransformMatrix(): Matrix;
  9695. /**
  9696. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9697. * Cube and 2D textures for instance.
  9698. */
  9699. recreateShadowMap(): void;
  9700. private _disposeBlurPostProcesses;
  9701. private _disposeRTTandPostProcesses;
  9702. /**
  9703. * Disposes the ShadowGenerator.
  9704. * Returns nothing.
  9705. */
  9706. dispose(): void;
  9707. /**
  9708. * Serializes the shadow generator setup to a json object.
  9709. * @returns The serialized JSON object
  9710. */
  9711. serialize(): any;
  9712. /**
  9713. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9714. * @param parsedShadowGenerator The JSON object to parse
  9715. * @param scene The scene to create the shadow map for
  9716. * @returns The parsed shadow generator
  9717. */
  9718. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9719. }
  9720. }
  9721. declare module BABYLON {
  9722. /**
  9723. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9724. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9725. * 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.
  9726. */
  9727. export abstract class Light extends Node {
  9728. /**
  9729. * Falloff Default: light is falling off following the material specification:
  9730. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9731. */
  9732. static readonly FALLOFF_DEFAULT: number;
  9733. /**
  9734. * Falloff Physical: light is falling off following the inverse squared distance law.
  9735. */
  9736. static readonly FALLOFF_PHYSICAL: number;
  9737. /**
  9738. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9739. * to enhance interoperability with other engines.
  9740. */
  9741. static readonly FALLOFF_GLTF: number;
  9742. /**
  9743. * Falloff Standard: light is falling off like in the standard material
  9744. * to enhance interoperability with other materials.
  9745. */
  9746. static readonly FALLOFF_STANDARD: number;
  9747. /**
  9748. * If every light affecting the material is in this lightmapMode,
  9749. * material.lightmapTexture adds or multiplies
  9750. * (depends on material.useLightmapAsShadowmap)
  9751. * after every other light calculations.
  9752. */
  9753. static readonly LIGHTMAP_DEFAULT: number;
  9754. /**
  9755. * material.lightmapTexture as only diffuse lighting from this light
  9756. * adds only specular lighting from this light
  9757. * adds dynamic shadows
  9758. */
  9759. static readonly LIGHTMAP_SPECULAR: number;
  9760. /**
  9761. * material.lightmapTexture as only lighting
  9762. * no light calculation from this light
  9763. * only adds dynamic shadows from this light
  9764. */
  9765. static readonly LIGHTMAP_SHADOWSONLY: number;
  9766. /**
  9767. * Each light type uses the default quantity according to its type:
  9768. * point/spot lights use luminous intensity
  9769. * directional lights use illuminance
  9770. */
  9771. static readonly INTENSITYMODE_AUTOMATIC: number;
  9772. /**
  9773. * lumen (lm)
  9774. */
  9775. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9776. /**
  9777. * candela (lm/sr)
  9778. */
  9779. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9780. /**
  9781. * lux (lm/m^2)
  9782. */
  9783. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9784. /**
  9785. * nit (cd/m^2)
  9786. */
  9787. static readonly INTENSITYMODE_LUMINANCE: number;
  9788. /**
  9789. * Light type const id of the point light.
  9790. */
  9791. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9792. /**
  9793. * Light type const id of the directional light.
  9794. */
  9795. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9796. /**
  9797. * Light type const id of the spot light.
  9798. */
  9799. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9800. /**
  9801. * Light type const id of the hemispheric light.
  9802. */
  9803. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9804. /**
  9805. * Diffuse gives the basic color to an object.
  9806. */
  9807. diffuse: Color3;
  9808. /**
  9809. * Specular produces a highlight color on an object.
  9810. * Note: This is note affecting PBR materials.
  9811. */
  9812. specular: Color3;
  9813. /**
  9814. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9815. * falling off base on range or angle.
  9816. * This can be set to any values in Light.FALLOFF_x.
  9817. *
  9818. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9819. * other types of materials.
  9820. */
  9821. falloffType: number;
  9822. /**
  9823. * Strength of the light.
  9824. * Note: By default it is define in the framework own unit.
  9825. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9826. */
  9827. intensity: number;
  9828. private _range;
  9829. protected _inverseSquaredRange: number;
  9830. /**
  9831. * Defines how far from the source the light is impacting in scene units.
  9832. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9833. */
  9834. /**
  9835. * Defines how far from the source the light is impacting in scene units.
  9836. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9837. */
  9838. range: number;
  9839. /**
  9840. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9841. * of light.
  9842. */
  9843. private _photometricScale;
  9844. private _intensityMode;
  9845. /**
  9846. * Gets the photometric scale used to interpret the intensity.
  9847. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9848. */
  9849. /**
  9850. * Sets the photometric scale used to interpret the intensity.
  9851. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9852. */
  9853. intensityMode: number;
  9854. private _radius;
  9855. /**
  9856. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9857. */
  9858. /**
  9859. * sets the light radius used by PBR Materials to simulate soft area lights.
  9860. */
  9861. radius: number;
  9862. private _renderPriority;
  9863. /**
  9864. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9865. * exceeding the number allowed of the materials.
  9866. */
  9867. renderPriority: number;
  9868. private _shadowEnabled;
  9869. /**
  9870. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9871. * the current shadow generator.
  9872. */
  9873. /**
  9874. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9875. * the current shadow generator.
  9876. */
  9877. shadowEnabled: boolean;
  9878. private _includedOnlyMeshes;
  9879. /**
  9880. * Gets the only meshes impacted by this light.
  9881. */
  9882. /**
  9883. * Sets the only meshes impacted by this light.
  9884. */
  9885. includedOnlyMeshes: AbstractMesh[];
  9886. private _excludedMeshes;
  9887. /**
  9888. * Gets the meshes not impacted by this light.
  9889. */
  9890. /**
  9891. * Sets the meshes not impacted by this light.
  9892. */
  9893. excludedMeshes: AbstractMesh[];
  9894. private _excludeWithLayerMask;
  9895. /**
  9896. * Gets the layer id use to find what meshes are not impacted by the light.
  9897. * Inactive if 0
  9898. */
  9899. /**
  9900. * Sets the layer id use to find what meshes are not impacted by the light.
  9901. * Inactive if 0
  9902. */
  9903. excludeWithLayerMask: number;
  9904. private _includeOnlyWithLayerMask;
  9905. /**
  9906. * Gets the layer id use to find what meshes are impacted by the light.
  9907. * Inactive if 0
  9908. */
  9909. /**
  9910. * Sets the layer id use to find what meshes are impacted by the light.
  9911. * Inactive if 0
  9912. */
  9913. includeOnlyWithLayerMask: number;
  9914. private _lightmapMode;
  9915. /**
  9916. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9917. */
  9918. /**
  9919. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9920. */
  9921. lightmapMode: number;
  9922. /**
  9923. * Shadow generator associted to the light.
  9924. * @hidden Internal use only.
  9925. */
  9926. _shadowGenerator: Nullable<IShadowGenerator>;
  9927. /**
  9928. * @hidden Internal use only.
  9929. */
  9930. _excludedMeshesIds: string[];
  9931. /**
  9932. * @hidden Internal use only.
  9933. */
  9934. _includedOnlyMeshesIds: string[];
  9935. /**
  9936. * The current light unifom buffer.
  9937. * @hidden Internal use only.
  9938. */
  9939. _uniformBuffer: UniformBuffer;
  9940. /**
  9941. * Creates a Light object in the scene.
  9942. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9943. * @param name The firendly name of the light
  9944. * @param scene The scene the light belongs too
  9945. */
  9946. constructor(name: string, scene: Scene);
  9947. protected abstract _buildUniformLayout(): void;
  9948. /**
  9949. * Sets the passed Effect "effect" with the Light information.
  9950. * @param effect The effect to update
  9951. * @param lightIndex The index of the light in the effect to update
  9952. * @returns The light
  9953. */
  9954. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9955. /**
  9956. * Sets the passed Effect "effect" with the Light information.
  9957. * @param effect The effect to update
  9958. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9959. * @returns The light
  9960. */
  9961. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9962. /**
  9963. * Returns the string "Light".
  9964. * @returns the class name
  9965. */
  9966. getClassName(): string;
  9967. /** @hidden */
  9968. readonly _isLight: boolean;
  9969. /**
  9970. * Converts the light information to a readable string for debug purpose.
  9971. * @param fullDetails Supports for multiple levels of logging within scene loading
  9972. * @returns the human readable light info
  9973. */
  9974. toString(fullDetails?: boolean): string;
  9975. /** @hidden */
  9976. protected _syncParentEnabledState(): void;
  9977. /**
  9978. * Set the enabled state of this node.
  9979. * @param value - the new enabled state
  9980. */
  9981. setEnabled(value: boolean): void;
  9982. /**
  9983. * Returns the Light associated shadow generator if any.
  9984. * @return the associated shadow generator.
  9985. */
  9986. getShadowGenerator(): Nullable<IShadowGenerator>;
  9987. /**
  9988. * Returns a Vector3, the absolute light position in the World.
  9989. * @returns the world space position of the light
  9990. */
  9991. getAbsolutePosition(): Vector3;
  9992. /**
  9993. * Specifies if the light will affect the passed mesh.
  9994. * @param mesh The mesh to test against the light
  9995. * @return true the mesh is affected otherwise, false.
  9996. */
  9997. canAffectMesh(mesh: AbstractMesh): boolean;
  9998. /**
  9999. * Sort function to order lights for rendering.
  10000. * @param a First Light object to compare to second.
  10001. * @param b Second Light object to compare first.
  10002. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10003. */
  10004. static CompareLightsPriority(a: Light, b: Light): number;
  10005. /**
  10006. * Releases resources associated with this node.
  10007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10009. */
  10010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10011. /**
  10012. * Returns the light type ID (integer).
  10013. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10014. */
  10015. getTypeID(): number;
  10016. /**
  10017. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10018. * @returns the scaled intensity in intensity mode unit
  10019. */
  10020. getScaledIntensity(): number;
  10021. /**
  10022. * Returns a new Light object, named "name", from the current one.
  10023. * @param name The name of the cloned light
  10024. * @returns the new created light
  10025. */
  10026. clone(name: string): Nullable<Light>;
  10027. /**
  10028. * Serializes the current light into a Serialization object.
  10029. * @returns the serialized object.
  10030. */
  10031. serialize(): any;
  10032. /**
  10033. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10034. * This new light is named "name" and added to the passed scene.
  10035. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10036. * @param name The friendly name of the light
  10037. * @param scene The scene the new light will belong to
  10038. * @returns the constructor function
  10039. */
  10040. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10041. /**
  10042. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10043. * @param parsedLight The JSON representation of the light
  10044. * @param scene The scene to create the parsed light in
  10045. * @returns the created light after parsing
  10046. */
  10047. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10048. private _hookArrayForExcluded;
  10049. private _hookArrayForIncludedOnly;
  10050. private _resyncMeshes;
  10051. /**
  10052. * Forces the meshes to update their light related information in their rendering used effects
  10053. * @hidden Internal Use Only
  10054. */
  10055. _markMeshesAsLightDirty(): void;
  10056. /**
  10057. * Recomputes the cached photometric scale if needed.
  10058. */
  10059. private _computePhotometricScale;
  10060. /**
  10061. * Returns the Photometric Scale according to the light type and intensity mode.
  10062. */
  10063. private _getPhotometricScale;
  10064. /**
  10065. * Reorder the light in the scene according to their defined priority.
  10066. * @hidden Internal Use Only
  10067. */
  10068. _reorderLightsInScene(): void;
  10069. /**
  10070. * Prepares the list of defines specific to the light type.
  10071. * @param defines the list of defines
  10072. * @param lightIndex defines the index of the light for the effect
  10073. */
  10074. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10075. }
  10076. }
  10077. declare module BABYLON {
  10078. /**
  10079. * Interface used to define Action
  10080. */
  10081. export interface IAction {
  10082. /**
  10083. * Trigger for the action
  10084. */
  10085. trigger: number;
  10086. /** Options of the trigger */
  10087. triggerOptions: any;
  10088. /**
  10089. * Gets the trigger parameters
  10090. * @returns the trigger parameters
  10091. */
  10092. getTriggerParameter(): any;
  10093. /**
  10094. * Internal only - executes current action event
  10095. * @hidden
  10096. */
  10097. _executeCurrent(evt?: ActionEvent): void;
  10098. /**
  10099. * Serialize placeholder for child classes
  10100. * @param parent of child
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. /**
  10105. * Internal only
  10106. * @hidden
  10107. */
  10108. _prepare(): void;
  10109. /**
  10110. * Internal only - manager for action
  10111. * @hidden
  10112. */
  10113. _actionManager: AbstractActionManager;
  10114. /**
  10115. * Adds action to chain of actions, may be a DoNothingAction
  10116. * @param action defines the next action to execute
  10117. * @returns The action passed in
  10118. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10119. */
  10120. then(action: IAction): IAction;
  10121. }
  10122. /**
  10123. * The action to be carried out following a trigger
  10124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10125. */
  10126. export class Action implements IAction {
  10127. /** the trigger, with or without parameters, for the action */
  10128. triggerOptions: any;
  10129. /**
  10130. * Trigger for the action
  10131. */
  10132. trigger: number;
  10133. /**
  10134. * Internal only - manager for action
  10135. * @hidden
  10136. */
  10137. _actionManager: ActionManager;
  10138. private _nextActiveAction;
  10139. private _child;
  10140. private _condition?;
  10141. private _triggerParameter;
  10142. /**
  10143. * An event triggered prior to action being executed.
  10144. */
  10145. onBeforeExecuteObservable: Observable<Action>;
  10146. /**
  10147. * Creates a new Action
  10148. * @param triggerOptions the trigger, with or without parameters, for the action
  10149. * @param condition an optional determinant of action
  10150. */
  10151. constructor(
  10152. /** the trigger, with or without parameters, for the action */
  10153. triggerOptions: any, condition?: Condition);
  10154. /**
  10155. * Internal only
  10156. * @hidden
  10157. */
  10158. _prepare(): void;
  10159. /**
  10160. * Gets the trigger parameters
  10161. * @returns the trigger parameters
  10162. */
  10163. getTriggerParameter(): any;
  10164. /**
  10165. * Internal only - executes current action event
  10166. * @hidden
  10167. */
  10168. _executeCurrent(evt?: ActionEvent): void;
  10169. /**
  10170. * Execute placeholder for child classes
  10171. * @param evt optional action event
  10172. */
  10173. execute(evt?: ActionEvent): void;
  10174. /**
  10175. * Skips to next active action
  10176. */
  10177. skipToNextActiveAction(): void;
  10178. /**
  10179. * Adds action to chain of actions, may be a DoNothingAction
  10180. * @param action defines the next action to execute
  10181. * @returns The action passed in
  10182. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10183. */
  10184. then(action: Action): Action;
  10185. /**
  10186. * Internal only
  10187. * @hidden
  10188. */
  10189. _getProperty(propertyPath: string): string;
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _getEffectiveTarget(target: any, propertyPath: string): any;
  10195. /**
  10196. * Serialize placeholder for child classes
  10197. * @param parent of child
  10198. * @returns the serialized object
  10199. */
  10200. serialize(parent: any): any;
  10201. /**
  10202. * Internal only called by serialize
  10203. * @hidden
  10204. */
  10205. protected _serialize(serializedAction: any, parent?: any): any;
  10206. /**
  10207. * Internal only
  10208. * @hidden
  10209. */
  10210. static _SerializeValueAsString: (value: any) => string;
  10211. /**
  10212. * Internal only
  10213. * @hidden
  10214. */
  10215. static _GetTargetProperty: (target: Node | Scene) => {
  10216. name: string;
  10217. targetType: string;
  10218. value: string;
  10219. };
  10220. }
  10221. }
  10222. declare module BABYLON {
  10223. /**
  10224. * A Condition applied to an Action
  10225. */
  10226. export class Condition {
  10227. /**
  10228. * Internal only - manager for action
  10229. * @hidden
  10230. */
  10231. _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. _evaluationId: number;
  10237. /**
  10238. * Internal only
  10239. * @hidden
  10240. */
  10241. _currentResult: boolean;
  10242. /**
  10243. * Creates a new Condition
  10244. * @param actionManager the manager of the action the condition is applied to
  10245. */
  10246. constructor(actionManager: ActionManager);
  10247. /**
  10248. * Check if the current condition is valid
  10249. * @returns a boolean
  10250. */
  10251. isValid(): boolean;
  10252. /**
  10253. * Internal only
  10254. * @hidden
  10255. */
  10256. _getProperty(propertyPath: string): string;
  10257. /**
  10258. * Internal only
  10259. * @hidden
  10260. */
  10261. _getEffectiveTarget(target: any, propertyPath: string): any;
  10262. /**
  10263. * Serialize placeholder for child classes
  10264. * @returns the serialized object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Internal only
  10269. * @hidden
  10270. */
  10271. protected _serialize(serializedCondition: any): any;
  10272. }
  10273. /**
  10274. * Defines specific conditional operators as extensions of Condition
  10275. */
  10276. export class ValueCondition extends Condition {
  10277. /** path to specify the property of the target the conditional operator uses */
  10278. propertyPath: string;
  10279. /** the value compared by the conditional operator against the current value of the property */
  10280. value: any;
  10281. /** the conditional operator, default ValueCondition.IsEqual */
  10282. operator: number;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. private static _IsEqual;
  10288. /**
  10289. * Internal only
  10290. * @hidden
  10291. */
  10292. private static _IsDifferent;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. private static _IsGreater;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. private static _IsLesser;
  10303. /**
  10304. * returns the number for IsEqual
  10305. */
  10306. static readonly IsEqual: number;
  10307. /**
  10308. * Returns the number for IsDifferent
  10309. */
  10310. static readonly IsDifferent: number;
  10311. /**
  10312. * Returns the number for IsGreater
  10313. */
  10314. static readonly IsGreater: number;
  10315. /**
  10316. * Returns the number for IsLesser
  10317. */
  10318. static readonly IsLesser: number;
  10319. /**
  10320. * Internal only The action manager for the condition
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. private _target;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. private _effectiveTarget;
  10334. /**
  10335. * Internal only
  10336. * @hidden
  10337. */
  10338. private _property;
  10339. /**
  10340. * Creates a new ValueCondition
  10341. * @param actionManager manager for the action the condition applies to
  10342. * @param target for the action
  10343. * @param propertyPath path to specify the property of the target the conditional operator uses
  10344. * @param value the value compared by the conditional operator against the current value of the property
  10345. * @param operator the conditional operator, default ValueCondition.IsEqual
  10346. */
  10347. constructor(actionManager: ActionManager, target: any,
  10348. /** path to specify the property of the target the conditional operator uses */
  10349. propertyPath: string,
  10350. /** the value compared by the conditional operator against the current value of the property */
  10351. value: any,
  10352. /** the conditional operator, default ValueCondition.IsEqual */
  10353. operator?: number);
  10354. /**
  10355. * Compares the given value with the property value for the specified conditional operator
  10356. * @returns the result of the comparison
  10357. */
  10358. isValid(): boolean;
  10359. /**
  10360. * Serialize the ValueCondition into a JSON compatible object
  10361. * @returns serialization object
  10362. */
  10363. serialize(): any;
  10364. /**
  10365. * Gets the name of the conditional operator for the ValueCondition
  10366. * @param operator the conditional operator
  10367. * @returns the name
  10368. */
  10369. static GetOperatorName(operator: number): string;
  10370. }
  10371. /**
  10372. * Defines a predicate condition as an extension of Condition
  10373. */
  10374. export class PredicateCondition extends Condition {
  10375. /** defines the predicate function used to validate the condition */
  10376. predicate: () => boolean;
  10377. /**
  10378. * Internal only - manager for action
  10379. * @hidden
  10380. */
  10381. _actionManager: ActionManager;
  10382. /**
  10383. * Creates a new PredicateCondition
  10384. * @param actionManager manager for the action the condition applies to
  10385. * @param predicate defines the predicate function used to validate the condition
  10386. */
  10387. constructor(actionManager: ActionManager,
  10388. /** defines the predicate function used to validate the condition */
  10389. predicate: () => boolean);
  10390. /**
  10391. * @returns the validity of the predicate condition
  10392. */
  10393. isValid(): boolean;
  10394. }
  10395. /**
  10396. * Defines a state condition as an extension of Condition
  10397. */
  10398. export class StateCondition extends Condition {
  10399. /** Value to compare with target state */
  10400. value: string;
  10401. /**
  10402. * Internal only - manager for action
  10403. * @hidden
  10404. */
  10405. _actionManager: ActionManager;
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */
  10410. private _target;
  10411. /**
  10412. * Creates a new StateCondition
  10413. * @param actionManager manager for the action the condition applies to
  10414. * @param target of the condition
  10415. * @param value to compare with target state
  10416. */
  10417. constructor(actionManager: ActionManager, target: any,
  10418. /** Value to compare with target state */
  10419. value: string);
  10420. /**
  10421. * Gets a boolean indicating if the current condition is met
  10422. * @returns the validity of the state
  10423. */
  10424. isValid(): boolean;
  10425. /**
  10426. * Serialize the StateCondition into a JSON compatible object
  10427. * @returns serialization object
  10428. */
  10429. serialize(): any;
  10430. }
  10431. }
  10432. declare module BABYLON {
  10433. /**
  10434. * This defines an action responsible to toggle a boolean once triggered.
  10435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10436. */
  10437. export class SwitchBooleanAction extends Action {
  10438. /**
  10439. * The path to the boolean property in the target object
  10440. */
  10441. propertyPath: string;
  10442. private _target;
  10443. private _effectiveTarget;
  10444. private _property;
  10445. /**
  10446. * Instantiate the action
  10447. * @param triggerOptions defines the trigger options
  10448. * @param target defines the object containing the boolean
  10449. * @param propertyPath defines the path to the boolean property in the target object
  10450. * @param condition defines the trigger related conditions
  10451. */
  10452. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10453. /** @hidden */
  10454. _prepare(): void;
  10455. /**
  10456. * Execute the action toggle the boolean value.
  10457. */
  10458. execute(): void;
  10459. /**
  10460. * Serializes the actions and its related information.
  10461. * @param parent defines the object to serialize in
  10462. * @returns the serialized object
  10463. */
  10464. serialize(parent: any): any;
  10465. }
  10466. /**
  10467. * This defines an action responsible to set a the state field of the target
  10468. * to a desired value once triggered.
  10469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10470. */
  10471. export class SetStateAction extends Action {
  10472. /**
  10473. * The value to store in the state field.
  10474. */
  10475. value: string;
  10476. private _target;
  10477. /**
  10478. * Instantiate the action
  10479. * @param triggerOptions defines the trigger options
  10480. * @param target defines the object containing the state property
  10481. * @param value defines the value to store in the state field
  10482. * @param condition defines the trigger related conditions
  10483. */
  10484. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10485. /**
  10486. * Execute the action and store the value on the target state property.
  10487. */
  10488. execute(): void;
  10489. /**
  10490. * Serializes the actions and its related information.
  10491. * @param parent defines the object to serialize in
  10492. * @returns the serialized object
  10493. */
  10494. serialize(parent: any): any;
  10495. }
  10496. /**
  10497. * This defines an action responsible to set a property of the target
  10498. * to a desired value once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SetValueAction extends Action {
  10502. /**
  10503. * The path of the property to set in the target.
  10504. */
  10505. propertyPath: string;
  10506. /**
  10507. * The value to set in the property
  10508. */
  10509. value: any;
  10510. private _target;
  10511. private _effectiveTarget;
  10512. private _property;
  10513. /**
  10514. * Instantiate the action
  10515. * @param triggerOptions defines the trigger options
  10516. * @param target defines the object containing the property
  10517. * @param propertyPath defines the path of the property to set in the target
  10518. * @param value defines the value to set in the property
  10519. * @param condition defines the trigger related conditions
  10520. */
  10521. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10522. /** @hidden */
  10523. _prepare(): void;
  10524. /**
  10525. * Execute the action and set the targetted property to the desired value.
  10526. */
  10527. execute(): void;
  10528. /**
  10529. * Serializes the actions and its related information.
  10530. * @param parent defines the object to serialize in
  10531. * @returns the serialized object
  10532. */
  10533. serialize(parent: any): any;
  10534. }
  10535. /**
  10536. * This defines an action responsible to increment the target value
  10537. * to a desired value once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class IncrementValueAction extends Action {
  10541. /**
  10542. * The path of the property to increment in the target.
  10543. */
  10544. propertyPath: string;
  10545. /**
  10546. * The value we should increment the property by.
  10547. */
  10548. value: any;
  10549. private _target;
  10550. private _effectiveTarget;
  10551. private _property;
  10552. /**
  10553. * Instantiate the action
  10554. * @param triggerOptions defines the trigger options
  10555. * @param target defines the object containing the property
  10556. * @param propertyPath defines the path of the property to increment in the target
  10557. * @param value defines the value value we should increment the property by
  10558. * @param condition defines the trigger related conditions
  10559. */
  10560. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10561. /** @hidden */
  10562. _prepare(): void;
  10563. /**
  10564. * Execute the action and increment the target of the value amount.
  10565. */
  10566. execute(): void;
  10567. /**
  10568. * Serializes the actions and its related information.
  10569. * @param parent defines the object to serialize in
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. }
  10574. /**
  10575. * This defines an action responsible to start an animation once triggered.
  10576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10577. */
  10578. export class PlayAnimationAction extends Action {
  10579. /**
  10580. * Where the animation should start (animation frame)
  10581. */
  10582. from: number;
  10583. /**
  10584. * Where the animation should stop (animation frame)
  10585. */
  10586. to: number;
  10587. /**
  10588. * Define if the animation should loop or stop after the first play.
  10589. */
  10590. loop?: boolean;
  10591. private _target;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the target animation or animation name
  10596. * @param from defines from where the animation should start (animation frame)
  10597. * @param end defines where the animation should stop (animation frame)
  10598. * @param loop defines if the animation should loop or stop after the first play
  10599. * @param condition defines the trigger related conditions
  10600. */
  10601. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10602. /** @hidden */
  10603. _prepare(): void;
  10604. /**
  10605. * Execute the action and play the animation.
  10606. */
  10607. execute(): void;
  10608. /**
  10609. * Serializes the actions and its related information.
  10610. * @param parent defines the object to serialize in
  10611. * @returns the serialized object
  10612. */
  10613. serialize(parent: any): any;
  10614. }
  10615. /**
  10616. * This defines an action responsible to stop an animation once triggered.
  10617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10618. */
  10619. export class StopAnimationAction extends Action {
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the target animation or animation name
  10625. * @param condition defines the trigger related conditions
  10626. */
  10627. constructor(triggerOptions: any, target: any, condition?: Condition);
  10628. /** @hidden */
  10629. _prepare(): void;
  10630. /**
  10631. * Execute the action and stop the animation.
  10632. */
  10633. execute(): void;
  10634. /**
  10635. * Serializes the actions and its related information.
  10636. * @param parent defines the object to serialize in
  10637. * @returns the serialized object
  10638. */
  10639. serialize(parent: any): any;
  10640. }
  10641. /**
  10642. * This defines an action responsible that does nothing once triggered.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class DoNothingAction extends Action {
  10646. /**
  10647. * Instantiate the action
  10648. * @param triggerOptions defines the trigger options
  10649. * @param condition defines the trigger related conditions
  10650. */
  10651. constructor(triggerOptions?: any, condition?: Condition);
  10652. /**
  10653. * Execute the action and do nothing.
  10654. */
  10655. execute(): void;
  10656. /**
  10657. * Serializes the actions and its related information.
  10658. * @param parent defines the object to serialize in
  10659. * @returns the serialized object
  10660. */
  10661. serialize(parent: any): any;
  10662. }
  10663. /**
  10664. * This defines an action responsible to trigger several actions once triggered.
  10665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10666. */
  10667. export class CombineAction extends Action {
  10668. /**
  10669. * The list of aggregated animations to run.
  10670. */
  10671. children: Action[];
  10672. /**
  10673. * Instantiate the action
  10674. * @param triggerOptions defines the trigger options
  10675. * @param children defines the list of aggregated animations to run
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action and executes all the aggregated actions.
  10683. */
  10684. execute(evt: ActionEvent): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to run code (external event) once triggered.
  10694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10695. */
  10696. export class ExecuteCodeAction extends Action {
  10697. /**
  10698. * The callback function to run.
  10699. */
  10700. func: (evt: ActionEvent) => void;
  10701. /**
  10702. * Instantiate the action
  10703. * @param triggerOptions defines the trigger options
  10704. * @param func defines the callback function to run
  10705. * @param condition defines the trigger related conditions
  10706. */
  10707. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10708. /**
  10709. * Execute the action and run the attached code.
  10710. */
  10711. execute(evt: ActionEvent): void;
  10712. }
  10713. /**
  10714. * This defines an action responsible to set the parent property of the target once triggered.
  10715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10716. */
  10717. export class SetParentAction extends Action {
  10718. private _parent;
  10719. private _target;
  10720. /**
  10721. * Instantiate the action
  10722. * @param triggerOptions defines the trigger options
  10723. * @param target defines the target containing the parent property
  10724. * @param parent defines from where the animation should start (animation frame)
  10725. * @param condition defines the trigger related conditions
  10726. */
  10727. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10728. /** @hidden */
  10729. _prepare(): void;
  10730. /**
  10731. * Execute the action and set the parent property.
  10732. */
  10733. execute(): void;
  10734. /**
  10735. * Serializes the actions and its related information.
  10736. * @param parent defines the object to serialize in
  10737. * @returns the serialized object
  10738. */
  10739. serialize(parent: any): any;
  10740. }
  10741. }
  10742. declare module BABYLON {
  10743. /**
  10744. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10745. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class ActionManager extends AbstractActionManager {
  10749. /**
  10750. * Nothing
  10751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10752. */
  10753. static readonly NothingTrigger: number;
  10754. /**
  10755. * On pick
  10756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10757. */
  10758. static readonly OnPickTrigger: number;
  10759. /**
  10760. * On left pick
  10761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10762. */
  10763. static readonly OnLeftPickTrigger: number;
  10764. /**
  10765. * On right pick
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10767. */
  10768. static readonly OnRightPickTrigger: number;
  10769. /**
  10770. * On center pick
  10771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10772. */
  10773. static readonly OnCenterPickTrigger: number;
  10774. /**
  10775. * On pick down
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10777. */
  10778. static readonly OnPickDownTrigger: number;
  10779. /**
  10780. * On double pick
  10781. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10782. */
  10783. static readonly OnDoublePickTrigger: number;
  10784. /**
  10785. * On pick up
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10787. */
  10788. static readonly OnPickUpTrigger: number;
  10789. /**
  10790. * On pick out.
  10791. * This trigger will only be raised if you also declared a OnPickDown
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10793. */
  10794. static readonly OnPickOutTrigger: number;
  10795. /**
  10796. * On long press
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly OnLongPressTrigger: number;
  10800. /**
  10801. * On pointer over
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPointerOverTrigger: number;
  10805. /**
  10806. * On pointer out
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnPointerOutTrigger: number;
  10810. /**
  10811. * On every frame
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnEveryFrameTrigger: number;
  10815. /**
  10816. * On intersection enter
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnIntersectionEnterTrigger: number;
  10820. /**
  10821. * On intersection exit
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnIntersectionExitTrigger: number;
  10825. /**
  10826. * On key down
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnKeyDownTrigger: number;
  10830. /**
  10831. * On key up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnKeyUpTrigger: number;
  10835. private _scene;
  10836. /**
  10837. * Creates a new action manager
  10838. * @param scene defines the hosting scene
  10839. */
  10840. constructor(scene: Scene);
  10841. /**
  10842. * Releases all associated resources
  10843. */
  10844. dispose(): void;
  10845. /**
  10846. * Gets hosting scene
  10847. * @returns the hosting scene
  10848. */
  10849. getScene(): Scene;
  10850. /**
  10851. * Does this action manager handles actions of any of the given triggers
  10852. * @param triggers defines the triggers to be tested
  10853. * @return a boolean indicating whether one (or more) of the triggers is handled
  10854. */
  10855. hasSpecificTriggers(triggers: number[]): boolean;
  10856. /**
  10857. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10858. * speed.
  10859. * @param triggerA defines the trigger to be tested
  10860. * @param triggerB defines the trigger to be tested
  10861. * @return a boolean indicating whether one (or more) of the triggers is handled
  10862. */
  10863. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10864. /**
  10865. * Does this action manager handles actions of a given trigger
  10866. * @param trigger defines the trigger to be tested
  10867. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10868. * @return whether the trigger is handled
  10869. */
  10870. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10871. /**
  10872. * Does this action manager has pointer triggers
  10873. */
  10874. readonly hasPointerTriggers: boolean;
  10875. /**
  10876. * Does this action manager has pick triggers
  10877. */
  10878. readonly hasPickTriggers: boolean;
  10879. /**
  10880. * Registers an action to this action manager
  10881. * @param action defines the action to be registered
  10882. * @return the action amended (prepared) after registration
  10883. */
  10884. registerAction(action: IAction): Nullable<IAction>;
  10885. /**
  10886. * Unregisters an action to this action manager
  10887. * @param action defines the action to be unregistered
  10888. * @return a boolean indicating whether the action has been unregistered
  10889. */
  10890. unregisterAction(action: IAction): Boolean;
  10891. /**
  10892. * Process a specific trigger
  10893. * @param trigger defines the trigger to process
  10894. * @param evt defines the event details to be processed
  10895. */
  10896. processTrigger(trigger: number, evt?: IActionEvent): void;
  10897. /** @hidden */
  10898. _getEffectiveTarget(target: any, propertyPath: string): any;
  10899. /** @hidden */
  10900. _getProperty(propertyPath: string): string;
  10901. /**
  10902. * Serialize this manager to a JSON object
  10903. * @param name defines the property name to store this manager
  10904. * @returns a JSON representation of this manager
  10905. */
  10906. serialize(name: string): any;
  10907. /**
  10908. * Creates a new ActionManager from a JSON data
  10909. * @param parsedActions defines the JSON data to read from
  10910. * @param object defines the hosting mesh
  10911. * @param scene defines the hosting scene
  10912. */
  10913. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10914. /**
  10915. * Get a trigger name by index
  10916. * @param trigger defines the trigger index
  10917. * @returns a trigger name
  10918. */
  10919. static GetTriggerName(trigger: number): string;
  10920. }
  10921. }
  10922. declare module BABYLON {
  10923. /**
  10924. * Class representing a ray with position and direction
  10925. */
  10926. export class Ray {
  10927. /** origin point */
  10928. origin: Vector3;
  10929. /** direction */
  10930. direction: Vector3;
  10931. /** length of the ray */
  10932. length: number;
  10933. private static readonly TmpVector3;
  10934. private _tmpRay;
  10935. /**
  10936. * Creates a new ray
  10937. * @param origin origin point
  10938. * @param direction direction
  10939. * @param length length of the ray
  10940. */
  10941. constructor(
  10942. /** origin point */
  10943. origin: Vector3,
  10944. /** direction */
  10945. direction: Vector3,
  10946. /** length of the ray */
  10947. length?: number);
  10948. /**
  10949. * Checks if the ray intersects a box
  10950. * @param minimum bound of the box
  10951. * @param maximum bound of the box
  10952. * @param intersectionTreshold extra extend to be added to the box in all direction
  10953. * @returns if the box was hit
  10954. */
  10955. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10956. /**
  10957. * Checks if the ray intersects a box
  10958. * @param box the bounding box to check
  10959. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10960. * @returns if the box was hit
  10961. */
  10962. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10963. /**
  10964. * If the ray hits a sphere
  10965. * @param sphere the bounding sphere to check
  10966. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10967. * @returns true if it hits the sphere
  10968. */
  10969. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10970. /**
  10971. * If the ray hits a triange
  10972. * @param vertex0 triangle vertex
  10973. * @param vertex1 triangle vertex
  10974. * @param vertex2 triangle vertex
  10975. * @returns intersection information if hit
  10976. */
  10977. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10978. /**
  10979. * Checks if ray intersects a plane
  10980. * @param plane the plane to check
  10981. * @returns the distance away it was hit
  10982. */
  10983. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10984. /**
  10985. * Calculate the intercept of a ray on a given axis
  10986. * @param axis to check 'x' | 'y' | 'z'
  10987. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10988. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10989. */
  10990. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10991. /**
  10992. * Checks if ray intersects a mesh
  10993. * @param mesh the mesh to check
  10994. * @param fastCheck if only the bounding box should checked
  10995. * @returns picking info of the intersecton
  10996. */
  10997. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10998. /**
  10999. * Checks if ray intersects a mesh
  11000. * @param meshes the meshes to check
  11001. * @param fastCheck if only the bounding box should checked
  11002. * @param results array to store result in
  11003. * @returns Array of picking infos
  11004. */
  11005. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11006. private _comparePickingInfo;
  11007. private static smallnum;
  11008. private static rayl;
  11009. /**
  11010. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11011. * @param sega the first point of the segment to test the intersection against
  11012. * @param segb the second point of the segment to test the intersection against
  11013. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11014. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11015. */
  11016. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11017. /**
  11018. * Update the ray from viewport position
  11019. * @param x position
  11020. * @param y y position
  11021. * @param viewportWidth viewport width
  11022. * @param viewportHeight viewport height
  11023. * @param world world matrix
  11024. * @param view view matrix
  11025. * @param projection projection matrix
  11026. * @returns this ray updated
  11027. */
  11028. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11029. /**
  11030. * Creates a ray with origin and direction of 0,0,0
  11031. * @returns the new ray
  11032. */
  11033. static Zero(): Ray;
  11034. /**
  11035. * Creates a new ray from screen space and viewport
  11036. * @param x position
  11037. * @param y y position
  11038. * @param viewportWidth viewport width
  11039. * @param viewportHeight viewport height
  11040. * @param world world matrix
  11041. * @param view view matrix
  11042. * @param projection projection matrix
  11043. * @returns new ray
  11044. */
  11045. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11046. /**
  11047. * 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
  11048. * transformed to the given world matrix.
  11049. * @param origin The origin point
  11050. * @param end The end point
  11051. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11052. * @returns the new ray
  11053. */
  11054. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11055. /**
  11056. * Transforms a ray by a matrix
  11057. * @param ray ray to transform
  11058. * @param matrix matrix to apply
  11059. * @returns the resulting new ray
  11060. */
  11061. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11062. /**
  11063. * Transforms a ray by a matrix
  11064. * @param ray ray to transform
  11065. * @param matrix matrix to apply
  11066. * @param result ray to store result in
  11067. */
  11068. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11069. /**
  11070. * Unproject a ray from screen space to object space
  11071. * @param sourceX defines the screen space x coordinate to use
  11072. * @param sourceY defines the screen space y coordinate to use
  11073. * @param viewportWidth defines the current width of the viewport
  11074. * @param viewportHeight defines the current height of the viewport
  11075. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11076. * @param view defines the view matrix to use
  11077. * @param projection defines the projection matrix to use
  11078. */
  11079. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11080. }
  11081. /**
  11082. * Type used to define predicate used to select faces when a mesh intersection is detected
  11083. */
  11084. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11085. interface Scene {
  11086. /** @hidden */
  11087. _tempPickingRay: Nullable<Ray>;
  11088. /** @hidden */
  11089. _cachedRayForTransform: Ray;
  11090. /** @hidden */
  11091. _pickWithRayInverseMatrix: Matrix;
  11092. /** @hidden */
  11093. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11094. /** @hidden */
  11095. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11096. }
  11097. }
  11098. declare module BABYLON {
  11099. /**
  11100. * Groups all the scene component constants in one place to ease maintenance.
  11101. * @hidden
  11102. */
  11103. export class SceneComponentConstants {
  11104. static readonly NAME_EFFECTLAYER: string;
  11105. static readonly NAME_LAYER: string;
  11106. static readonly NAME_LENSFLARESYSTEM: string;
  11107. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11108. static readonly NAME_PARTICLESYSTEM: string;
  11109. static readonly NAME_GAMEPAD: string;
  11110. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11111. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11112. static readonly NAME_DEPTHRENDERER: string;
  11113. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11114. static readonly NAME_SPRITE: string;
  11115. static readonly NAME_OUTLINERENDERER: string;
  11116. static readonly NAME_PROCEDURALTEXTURE: string;
  11117. static readonly NAME_SHADOWGENERATOR: string;
  11118. static readonly NAME_OCTREE: string;
  11119. static readonly NAME_PHYSICSENGINE: string;
  11120. static readonly NAME_AUDIO: string;
  11121. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11122. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11123. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11124. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11125. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11126. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11127. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11128. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11129. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11130. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11131. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11132. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11133. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11134. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11135. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11136. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11137. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11138. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11139. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11140. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11141. static readonly STEP_AFTERRENDER_AUDIO: number;
  11142. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11143. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11144. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11145. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11146. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11147. static readonly STEP_POINTERMOVE_SPRITE: number;
  11148. static readonly STEP_POINTERDOWN_SPRITE: number;
  11149. static readonly STEP_POINTERUP_SPRITE: number;
  11150. }
  11151. /**
  11152. * This represents a scene component.
  11153. *
  11154. * This is used to decouple the dependency the scene is having on the different workloads like
  11155. * layers, post processes...
  11156. */
  11157. export interface ISceneComponent {
  11158. /**
  11159. * The name of the component. Each component must have a unique name.
  11160. */
  11161. name: string;
  11162. /**
  11163. * The scene the component belongs to.
  11164. */
  11165. scene: Scene;
  11166. /**
  11167. * Register the component to one instance of a scene.
  11168. */
  11169. register(): void;
  11170. /**
  11171. * Rebuilds the elements related to this component in case of
  11172. * context lost for instance.
  11173. */
  11174. rebuild(): void;
  11175. /**
  11176. * Disposes the component and the associated ressources.
  11177. */
  11178. dispose(): void;
  11179. }
  11180. /**
  11181. * This represents a SERIALIZABLE scene component.
  11182. *
  11183. * This extends Scene Component to add Serialization methods on top.
  11184. */
  11185. export interface ISceneSerializableComponent extends ISceneComponent {
  11186. /**
  11187. * Adds all the elements from the container to the scene
  11188. * @param container the container holding the elements
  11189. */
  11190. addFromContainer(container: AbstractScene): void;
  11191. /**
  11192. * Removes all the elements in the container from the scene
  11193. * @param container contains the elements to remove
  11194. * @param dispose if the removed element should be disposed (default: false)
  11195. */
  11196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11197. /**
  11198. * Serializes the component data to the specified json object
  11199. * @param serializationObject The object to serialize to
  11200. */
  11201. serialize(serializationObject: any): void;
  11202. }
  11203. /**
  11204. * Strong typing of a Mesh related stage step action
  11205. */
  11206. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11207. /**
  11208. * Strong typing of a Evaluate Sub Mesh related stage step action
  11209. */
  11210. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11211. /**
  11212. * Strong typing of a Active Mesh related stage step action
  11213. */
  11214. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11215. /**
  11216. * Strong typing of a Camera related stage step action
  11217. */
  11218. export type CameraStageAction = (camera: Camera) => void;
  11219. /**
  11220. * Strong typing of a Camera Frame buffer related stage step action
  11221. */
  11222. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11223. /**
  11224. * Strong typing of a Render Target related stage step action
  11225. */
  11226. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11227. /**
  11228. * Strong typing of a RenderingGroup related stage step action
  11229. */
  11230. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11231. /**
  11232. * Strong typing of a Mesh Render related stage step action
  11233. */
  11234. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11235. /**
  11236. * Strong typing of a simple stage step action
  11237. */
  11238. export type SimpleStageAction = () => void;
  11239. /**
  11240. * Strong typing of a render target action.
  11241. */
  11242. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11243. /**
  11244. * Strong typing of a pointer move action.
  11245. */
  11246. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11247. /**
  11248. * Strong typing of a pointer up/down action.
  11249. */
  11250. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11251. /**
  11252. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11253. * @hidden
  11254. */
  11255. export class Stage<T extends Function> extends Array<{
  11256. index: number;
  11257. component: ISceneComponent;
  11258. action: T;
  11259. }> {
  11260. /**
  11261. * Hide ctor from the rest of the world.
  11262. * @param items The items to add.
  11263. */
  11264. private constructor();
  11265. /**
  11266. * Creates a new Stage.
  11267. * @returns A new instance of a Stage
  11268. */
  11269. static Create<T extends Function>(): Stage<T>;
  11270. /**
  11271. * Registers a step in an ordered way in the targeted stage.
  11272. * @param index Defines the position to register the step in
  11273. * @param component Defines the component attached to the step
  11274. * @param action Defines the action to launch during the step
  11275. */
  11276. registerStep(index: number, component: ISceneComponent, action: T): void;
  11277. /**
  11278. * Clears all the steps from the stage.
  11279. */
  11280. clear(): void;
  11281. }
  11282. }
  11283. declare module BABYLON {
  11284. interface Scene {
  11285. /** @hidden */
  11286. _pointerOverSprite: Nullable<Sprite>;
  11287. /** @hidden */
  11288. _pickedDownSprite: Nullable<Sprite>;
  11289. /** @hidden */
  11290. _tempSpritePickingRay: Nullable<Ray>;
  11291. /**
  11292. * All of the sprite managers added to this scene
  11293. * @see http://doc.babylonjs.com/babylon101/sprites
  11294. */
  11295. spriteManagers: Array<ISpriteManager>;
  11296. /**
  11297. * An event triggered when sprites rendering is about to start
  11298. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11299. */
  11300. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11301. /**
  11302. * An event triggered when sprites rendering is done
  11303. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11304. */
  11305. onAfterSpritesRenderingObservable: Observable<Scene>;
  11306. /** @hidden */
  11307. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11308. /** Launch a ray to try to pick a sprite in the scene
  11309. * @param x position on screen
  11310. * @param y position on screen
  11311. * @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
  11312. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11313. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11314. * @returns a PickingInfo
  11315. */
  11316. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11317. /** Use the given ray to pick a sprite in the scene
  11318. * @param ray The ray (in world space) to use to pick meshes
  11319. * @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
  11320. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11321. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11322. * @returns a PickingInfo
  11323. */
  11324. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11325. /** @hidden */
  11326. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11327. /** Launch a ray to try to pick sprites in the scene
  11328. * @param x position on screen
  11329. * @param y position on screen
  11330. * @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
  11331. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11332. * @returns a PickingInfo array
  11333. */
  11334. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11335. /** Use the given ray to pick sprites in the scene
  11336. * @param ray The ray (in world space) to use to pick meshes
  11337. * @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
  11338. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11339. * @returns a PickingInfo array
  11340. */
  11341. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11342. /**
  11343. * Force the sprite under the pointer
  11344. * @param sprite defines the sprite to use
  11345. */
  11346. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11347. /**
  11348. * Gets the sprite under the pointer
  11349. * @returns a Sprite or null if no sprite is under the pointer
  11350. */
  11351. getPointerOverSprite(): Nullable<Sprite>;
  11352. }
  11353. /**
  11354. * Defines the sprite scene component responsible to manage sprites
  11355. * in a given scene.
  11356. */
  11357. export class SpriteSceneComponent implements ISceneComponent {
  11358. /**
  11359. * The component name helpfull to identify the component in the list of scene components.
  11360. */
  11361. readonly name: string;
  11362. /**
  11363. * The scene the component belongs to.
  11364. */
  11365. scene: Scene;
  11366. /** @hidden */
  11367. private _spritePredicate;
  11368. /**
  11369. * Creates a new instance of the component for the given scene
  11370. * @param scene Defines the scene to register the component in
  11371. */
  11372. constructor(scene: Scene);
  11373. /**
  11374. * Registers the component in a given scene
  11375. */
  11376. register(): void;
  11377. /**
  11378. * Rebuilds the elements related to this component in case of
  11379. * context lost for instance.
  11380. */
  11381. rebuild(): void;
  11382. /**
  11383. * Disposes the component and the associated ressources.
  11384. */
  11385. dispose(): void;
  11386. private _pickSpriteButKeepRay;
  11387. private _pointerMove;
  11388. private _pointerDown;
  11389. private _pointerUp;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. /** @hidden */
  11394. export var fogFragmentDeclaration: {
  11395. name: string;
  11396. shader: string;
  11397. };
  11398. }
  11399. declare module BABYLON {
  11400. /** @hidden */
  11401. export var fogFragment: {
  11402. name: string;
  11403. shader: string;
  11404. };
  11405. }
  11406. declare module BABYLON {
  11407. /** @hidden */
  11408. export var spritesPixelShader: {
  11409. name: string;
  11410. shader: string;
  11411. };
  11412. }
  11413. declare module BABYLON {
  11414. /** @hidden */
  11415. export var fogVertexDeclaration: {
  11416. name: string;
  11417. shader: string;
  11418. };
  11419. }
  11420. declare module BABYLON {
  11421. /** @hidden */
  11422. export var spritesVertexShader: {
  11423. name: string;
  11424. shader: string;
  11425. };
  11426. }
  11427. declare module BABYLON {
  11428. /**
  11429. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11430. */
  11431. export interface ISpriteManager extends IDisposable {
  11432. /**
  11433. * Restricts the camera to viewing objects with the same layerMask.
  11434. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11435. */
  11436. layerMask: number;
  11437. /**
  11438. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11439. */
  11440. isPickable: boolean;
  11441. /**
  11442. * Specifies the rendering group id for this mesh (0 by default)
  11443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11444. */
  11445. renderingGroupId: number;
  11446. /**
  11447. * Defines the list of sprites managed by the manager.
  11448. */
  11449. sprites: Array<Sprite>;
  11450. /**
  11451. * Tests the intersection of a sprite with a specific ray.
  11452. * @param ray The ray we are sending to test the collision
  11453. * @param camera The camera space we are sending rays in
  11454. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11455. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11456. * @returns picking info or null.
  11457. */
  11458. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11459. /**
  11460. * Intersects the sprites with a ray
  11461. * @param ray defines the ray to intersect with
  11462. * @param camera defines the current active camera
  11463. * @param predicate defines a predicate used to select candidate sprites
  11464. * @returns null if no hit or a PickingInfo array
  11465. */
  11466. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11467. /**
  11468. * Renders the list of sprites on screen.
  11469. */
  11470. render(): void;
  11471. }
  11472. /**
  11473. * Class used to manage multiple sprites on the same spritesheet
  11474. * @see http://doc.babylonjs.com/babylon101/sprites
  11475. */
  11476. export class SpriteManager implements ISpriteManager {
  11477. /** defines the manager's name */
  11478. name: string;
  11479. /** Gets the list of sprites */
  11480. sprites: Sprite[];
  11481. /** Gets or sets the rendering group id (0 by default) */
  11482. renderingGroupId: number;
  11483. /** Gets or sets camera layer mask */
  11484. layerMask: number;
  11485. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11486. fogEnabled: boolean;
  11487. /** Gets or sets a boolean indicating if the sprites are pickable */
  11488. isPickable: boolean;
  11489. /** Defines the default width of a cell in the spritesheet */
  11490. cellWidth: number;
  11491. /** Defines the default height of a cell in the spritesheet */
  11492. cellHeight: number;
  11493. /** Associative array from JSON sprite data file */
  11494. private _cellData;
  11495. /** Array of sprite names from JSON sprite data file */
  11496. private _spriteMap;
  11497. /** True when packed cell data from JSON file is ready*/
  11498. private _packedAndReady;
  11499. /**
  11500. * An event triggered when the manager is disposed.
  11501. */
  11502. onDisposeObservable: Observable<SpriteManager>;
  11503. private _onDisposeObserver;
  11504. /**
  11505. * Callback called when the manager is disposed
  11506. */
  11507. onDispose: () => void;
  11508. private _capacity;
  11509. private _fromPacked;
  11510. private _spriteTexture;
  11511. private _epsilon;
  11512. private _scene;
  11513. private _vertexData;
  11514. private _buffer;
  11515. private _vertexBuffers;
  11516. private _indexBuffer;
  11517. private _effectBase;
  11518. private _effectFog;
  11519. /**
  11520. * Gets or sets the spritesheet texture
  11521. */
  11522. texture: Texture;
  11523. /**
  11524. * Creates a new sprite manager
  11525. * @param name defines the manager's name
  11526. * @param imgUrl defines the sprite sheet url
  11527. * @param capacity defines the maximum allowed number of sprites
  11528. * @param cellSize defines the size of a sprite cell
  11529. * @param scene defines the hosting scene
  11530. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11531. * @param samplingMode defines the smapling mode to use with spritesheet
  11532. * @param fromPacked set to false; do not alter
  11533. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11534. */
  11535. constructor(
  11536. /** defines the manager's name */
  11537. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11538. private _makePacked;
  11539. private _appendSpriteVertex;
  11540. /**
  11541. * Intersects the sprites with a ray
  11542. * @param ray defines the ray to intersect with
  11543. * @param camera defines the current active camera
  11544. * @param predicate defines a predicate used to select candidate sprites
  11545. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11546. * @returns null if no hit or a PickingInfo
  11547. */
  11548. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11549. /**
  11550. * Intersects the sprites with a ray
  11551. * @param ray defines the ray to intersect with
  11552. * @param camera defines the current active camera
  11553. * @param predicate defines a predicate used to select candidate sprites
  11554. * @returns null if no hit or a PickingInfo array
  11555. */
  11556. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11557. /**
  11558. * Render all child sprites
  11559. */
  11560. render(): void;
  11561. /**
  11562. * Release associated resources
  11563. */
  11564. dispose(): void;
  11565. }
  11566. }
  11567. declare module BABYLON {
  11568. /**
  11569. * Class used to represent a sprite
  11570. * @see http://doc.babylonjs.com/babylon101/sprites
  11571. */
  11572. export class Sprite {
  11573. /** defines the name */
  11574. name: string;
  11575. /** Gets or sets the current world position */
  11576. position: Vector3;
  11577. /** Gets or sets the main color */
  11578. color: Color4;
  11579. /** Gets or sets the width */
  11580. width: number;
  11581. /** Gets or sets the height */
  11582. height: number;
  11583. /** Gets or sets rotation angle */
  11584. angle: number;
  11585. /** Gets or sets the cell index in the sprite sheet */
  11586. cellIndex: number;
  11587. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11588. cellRef: string;
  11589. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11590. invertU: number;
  11591. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11592. invertV: number;
  11593. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11594. disposeWhenFinishedAnimating: boolean;
  11595. /** Gets the list of attached animations */
  11596. animations: Animation[];
  11597. /** Gets or sets a boolean indicating if the sprite can be picked */
  11598. isPickable: boolean;
  11599. /**
  11600. * Gets or sets the associated action manager
  11601. */
  11602. actionManager: Nullable<ActionManager>;
  11603. private _animationStarted;
  11604. private _loopAnimation;
  11605. private _fromIndex;
  11606. private _toIndex;
  11607. private _delay;
  11608. private _direction;
  11609. private _manager;
  11610. private _time;
  11611. private _onAnimationEnd;
  11612. /**
  11613. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11614. */
  11615. isVisible: boolean;
  11616. /**
  11617. * Gets or sets the sprite size
  11618. */
  11619. size: number;
  11620. /**
  11621. * Creates a new Sprite
  11622. * @param name defines the name
  11623. * @param manager defines the manager
  11624. */
  11625. constructor(
  11626. /** defines the name */
  11627. name: string, manager: ISpriteManager);
  11628. /**
  11629. * Starts an animation
  11630. * @param from defines the initial key
  11631. * @param to defines the end key
  11632. * @param loop defines if the animation must loop
  11633. * @param delay defines the start delay (in ms)
  11634. * @param onAnimationEnd defines a callback to call when animation ends
  11635. */
  11636. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11637. /** Stops current animation (if any) */
  11638. stopAnimation(): void;
  11639. /** @hidden */
  11640. _animate(deltaTime: number): void;
  11641. /** Release associated resources */
  11642. dispose(): void;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. /**
  11647. * Information about the result of picking within a scene
  11648. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11649. */
  11650. export class PickingInfo {
  11651. /** @hidden */
  11652. _pickingUnavailable: boolean;
  11653. /**
  11654. * If the pick collided with an object
  11655. */
  11656. hit: boolean;
  11657. /**
  11658. * Distance away where the pick collided
  11659. */
  11660. distance: number;
  11661. /**
  11662. * The location of pick collision
  11663. */
  11664. pickedPoint: Nullable<Vector3>;
  11665. /**
  11666. * The mesh corresponding the the pick collision
  11667. */
  11668. pickedMesh: Nullable<AbstractMesh>;
  11669. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11670. bu: number;
  11671. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11672. bv: number;
  11673. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11674. faceId: number;
  11675. /** Id of the the submesh that was picked */
  11676. subMeshId: number;
  11677. /** If a sprite was picked, this will be the sprite the pick collided with */
  11678. pickedSprite: Nullable<Sprite>;
  11679. /**
  11680. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11681. */
  11682. originMesh: Nullable<AbstractMesh>;
  11683. /**
  11684. * The ray that was used to perform the picking.
  11685. */
  11686. ray: Nullable<Ray>;
  11687. /**
  11688. * Gets the normal correspodning to the face the pick collided with
  11689. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11690. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11691. * @returns The normal correspodning to the face the pick collided with
  11692. */
  11693. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11694. /**
  11695. * Gets the texture coordinates of where the pick occured
  11696. * @returns the vector containing the coordnates of the texture
  11697. */
  11698. getTextureCoordinates(): Nullable<Vector2>;
  11699. }
  11700. }
  11701. declare module BABYLON {
  11702. /**
  11703. * Gather the list of pointer event types as constants.
  11704. */
  11705. export class PointerEventTypes {
  11706. /**
  11707. * 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.
  11708. */
  11709. static readonly POINTERDOWN: number;
  11710. /**
  11711. * The pointerup event is fired when a pointer is no longer active.
  11712. */
  11713. static readonly POINTERUP: number;
  11714. /**
  11715. * The pointermove event is fired when a pointer changes coordinates.
  11716. */
  11717. static readonly POINTERMOVE: number;
  11718. /**
  11719. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11720. */
  11721. static readonly POINTERWHEEL: number;
  11722. /**
  11723. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11724. */
  11725. static readonly POINTERPICK: number;
  11726. /**
  11727. * The pointertap event is fired when a the object has been touched and released without drag.
  11728. */
  11729. static readonly POINTERTAP: number;
  11730. /**
  11731. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11732. */
  11733. static readonly POINTERDOUBLETAP: number;
  11734. }
  11735. /**
  11736. * Base class of pointer info types.
  11737. */
  11738. export class PointerInfoBase {
  11739. /**
  11740. * Defines the type of event (PointerEventTypes)
  11741. */
  11742. type: number;
  11743. /**
  11744. * Defines the related dom event
  11745. */
  11746. event: PointerEvent | MouseWheelEvent;
  11747. /**
  11748. * Instantiates the base class of pointers info.
  11749. * @param type Defines the type of event (PointerEventTypes)
  11750. * @param event Defines the related dom event
  11751. */
  11752. constructor(
  11753. /**
  11754. * Defines the type of event (PointerEventTypes)
  11755. */
  11756. type: number,
  11757. /**
  11758. * Defines the related dom event
  11759. */
  11760. event: PointerEvent | MouseWheelEvent);
  11761. }
  11762. /**
  11763. * This class is used to store pointer related info for the onPrePointerObservable event.
  11764. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11765. */
  11766. export class PointerInfoPre extends PointerInfoBase {
  11767. /**
  11768. * Ray from a pointer if availible (eg. 6dof controller)
  11769. */
  11770. ray: Nullable<Ray>;
  11771. /**
  11772. * Defines the local position of the pointer on the canvas.
  11773. */
  11774. localPosition: Vector2;
  11775. /**
  11776. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11777. */
  11778. skipOnPointerObservable: boolean;
  11779. /**
  11780. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11781. * @param type Defines the type of event (PointerEventTypes)
  11782. * @param event Defines the related dom event
  11783. * @param localX Defines the local x coordinates of the pointer when the event occured
  11784. * @param localY Defines the local y coordinates of the pointer when the event occured
  11785. */
  11786. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11787. }
  11788. /**
  11789. * This type contains all the data related to a pointer event in Babylon.js.
  11790. * 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.
  11791. */
  11792. export class PointerInfo extends PointerInfoBase {
  11793. /**
  11794. * Defines the picking info associated to the info (if any)\
  11795. */
  11796. pickInfo: Nullable<PickingInfo>;
  11797. /**
  11798. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11799. * @param type Defines the type of event (PointerEventTypes)
  11800. * @param event Defines the related dom event
  11801. * @param pickInfo Defines the picking info associated to the info (if any)\
  11802. */
  11803. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11804. /**
  11805. * Defines the picking info associated to the info (if any)\
  11806. */
  11807. pickInfo: Nullable<PickingInfo>);
  11808. }
  11809. /**
  11810. * Data relating to a touch event on the screen.
  11811. */
  11812. export interface PointerTouch {
  11813. /**
  11814. * X coordinate of touch.
  11815. */
  11816. x: number;
  11817. /**
  11818. * Y coordinate of touch.
  11819. */
  11820. y: number;
  11821. /**
  11822. * Id of touch. Unique for each finger.
  11823. */
  11824. pointerId: number;
  11825. /**
  11826. * Event type passed from DOM.
  11827. */
  11828. type: any;
  11829. }
  11830. }
  11831. declare module BABYLON {
  11832. /**
  11833. * Manage the mouse inputs to control the movement of a free camera.
  11834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11835. */
  11836. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11837. /**
  11838. * Define if touch is enabled in the mouse input
  11839. */
  11840. touchEnabled: boolean;
  11841. /**
  11842. * Defines the camera the input is attached to.
  11843. */
  11844. camera: FreeCamera;
  11845. /**
  11846. * Defines the buttons associated with the input to handle camera move.
  11847. */
  11848. buttons: number[];
  11849. /**
  11850. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11851. */
  11852. angularSensibility: number;
  11853. private _pointerInput;
  11854. private _onMouseMove;
  11855. private _observer;
  11856. private previousPosition;
  11857. /**
  11858. * Observable for when a pointer move event occurs containing the move offset
  11859. */
  11860. onPointerMovedObservable: Observable<{
  11861. offsetX: number;
  11862. offsetY: number;
  11863. }>;
  11864. /**
  11865. * @hidden
  11866. * If the camera should be rotated automatically based on pointer movement
  11867. */
  11868. _allowCameraRotation: boolean;
  11869. /**
  11870. * Manage the mouse inputs to control the movement of a free camera.
  11871. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11872. * @param touchEnabled Defines if touch is enabled or not
  11873. */
  11874. constructor(
  11875. /**
  11876. * Define if touch is enabled in the mouse input
  11877. */
  11878. touchEnabled?: boolean);
  11879. /**
  11880. * Attach the input controls to a specific dom element to get the input from.
  11881. * @param element Defines the element the controls should be listened from
  11882. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11883. */
  11884. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11885. /**
  11886. * Called on JS contextmenu event.
  11887. * Override this method to provide functionality.
  11888. */
  11889. protected onContextMenu(evt: PointerEvent): void;
  11890. /**
  11891. * Detach the current controls from the specified dom element.
  11892. * @param element Defines the element to stop listening the inputs from
  11893. */
  11894. detachControl(element: Nullable<HTMLElement>): void;
  11895. /**
  11896. * Gets the class name of the current intput.
  11897. * @returns the class name
  11898. */
  11899. getClassName(): string;
  11900. /**
  11901. * Get the friendly name associated with the input class.
  11902. * @returns the input friendly name
  11903. */
  11904. getSimpleName(): string;
  11905. }
  11906. }
  11907. declare module BABYLON {
  11908. /**
  11909. * Manage the touch inputs to control the movement of a free camera.
  11910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11911. */
  11912. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11913. /**
  11914. * Defines the camera the input is attached to.
  11915. */
  11916. camera: FreeCamera;
  11917. /**
  11918. * Defines the touch sensibility for rotation.
  11919. * The higher the faster.
  11920. */
  11921. touchAngularSensibility: number;
  11922. /**
  11923. * Defines the touch sensibility for move.
  11924. * The higher the faster.
  11925. */
  11926. touchMoveSensibility: number;
  11927. private _offsetX;
  11928. private _offsetY;
  11929. private _pointerPressed;
  11930. private _pointerInput;
  11931. private _observer;
  11932. private _onLostFocus;
  11933. /**
  11934. * Attach the input controls to a specific dom element to get the input from.
  11935. * @param element Defines the element the controls should be listened from
  11936. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11937. */
  11938. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11939. /**
  11940. * Detach the current controls from the specified dom element.
  11941. * @param element Defines the element to stop listening the inputs from
  11942. */
  11943. detachControl(element: Nullable<HTMLElement>): void;
  11944. /**
  11945. * Update the current camera state depending on the inputs that have been used this frame.
  11946. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11947. */
  11948. checkInputs(): void;
  11949. /**
  11950. * Gets the class name of the current intput.
  11951. * @returns the class name
  11952. */
  11953. getClassName(): string;
  11954. /**
  11955. * Get the friendly name associated with the input class.
  11956. * @returns the input friendly name
  11957. */
  11958. getSimpleName(): string;
  11959. }
  11960. }
  11961. declare module BABYLON {
  11962. /**
  11963. * Default Inputs manager for the FreeCamera.
  11964. * It groups all the default supported inputs for ease of use.
  11965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11966. */
  11967. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11968. /**
  11969. * @hidden
  11970. */
  11971. _mouseInput: Nullable<FreeCameraMouseInput>;
  11972. /**
  11973. * Instantiates a new FreeCameraInputsManager.
  11974. * @param camera Defines the camera the inputs belong to
  11975. */
  11976. constructor(camera: FreeCamera);
  11977. /**
  11978. * Add keyboard input support to the input manager.
  11979. * @returns the current input manager
  11980. */
  11981. addKeyboard(): FreeCameraInputsManager;
  11982. /**
  11983. * Add mouse input support to the input manager.
  11984. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11985. * @returns the current input manager
  11986. */
  11987. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11988. /**
  11989. * Removes the mouse input support from the manager
  11990. * @returns the current input manager
  11991. */
  11992. removeMouse(): FreeCameraInputsManager;
  11993. /**
  11994. * Add touch input support to the input manager.
  11995. * @returns the current input manager
  11996. */
  11997. addTouch(): FreeCameraInputsManager;
  11998. /**
  11999. * Remove all attached input methods from a camera
  12000. */
  12001. clear(): void;
  12002. }
  12003. }
  12004. declare module BABYLON {
  12005. /**
  12006. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12007. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12008. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12009. */
  12010. export class FreeCamera extends TargetCamera {
  12011. /**
  12012. * Define the collision ellipsoid of the camera.
  12013. * This is helpful to simulate a camera body like the player body around the camera
  12014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12015. */
  12016. ellipsoid: Vector3;
  12017. /**
  12018. * Define an offset for the position of the ellipsoid around the camera.
  12019. * This can be helpful to determine the center of the body near the gravity center of the body
  12020. * instead of its head.
  12021. */
  12022. ellipsoidOffset: Vector3;
  12023. /**
  12024. * Enable or disable collisions of the camera with the rest of the scene objects.
  12025. */
  12026. checkCollisions: boolean;
  12027. /**
  12028. * Enable or disable gravity on the camera.
  12029. */
  12030. applyGravity: boolean;
  12031. /**
  12032. * Define the input manager associated to the camera.
  12033. */
  12034. inputs: FreeCameraInputsManager;
  12035. /**
  12036. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12037. * Higher values reduce sensitivity.
  12038. */
  12039. /**
  12040. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12041. * Higher values reduce sensitivity.
  12042. */
  12043. angularSensibility: number;
  12044. /**
  12045. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12046. */
  12047. keysUp: number[];
  12048. /**
  12049. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12050. */
  12051. keysDown: number[];
  12052. /**
  12053. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12054. */
  12055. keysLeft: number[];
  12056. /**
  12057. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12058. */
  12059. keysRight: number[];
  12060. /**
  12061. * Event raised when the camera collide with a mesh in the scene.
  12062. */
  12063. onCollide: (collidedMesh: AbstractMesh) => void;
  12064. private _collider;
  12065. private _needMoveForGravity;
  12066. private _oldPosition;
  12067. private _diffPosition;
  12068. private _newPosition;
  12069. /** @hidden */
  12070. _localDirection: Vector3;
  12071. /** @hidden */
  12072. _transformedDirection: Vector3;
  12073. /**
  12074. * Instantiates a Free Camera.
  12075. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12076. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12077. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12078. * @param name Define the name of the camera in the scene
  12079. * @param position Define the start position of the camera in the scene
  12080. * @param scene Define the scene the camera belongs to
  12081. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12082. */
  12083. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12084. /**
  12085. * Attached controls to the current camera.
  12086. * @param element Defines the element the controls should be listened from
  12087. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12088. */
  12089. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12090. /**
  12091. * Detach the current controls from the camera.
  12092. * The camera will stop reacting to inputs.
  12093. * @param element Defines the element to stop listening the inputs from
  12094. */
  12095. detachControl(element: HTMLElement): void;
  12096. private _collisionMask;
  12097. /**
  12098. * Define a collision mask to limit the list of object the camera can collide with
  12099. */
  12100. collisionMask: number;
  12101. /** @hidden */
  12102. _collideWithWorld(displacement: Vector3): void;
  12103. private _onCollisionPositionChange;
  12104. /** @hidden */
  12105. _checkInputs(): void;
  12106. /** @hidden */
  12107. _decideIfNeedsToMove(): boolean;
  12108. /** @hidden */
  12109. _updatePosition(): void;
  12110. /**
  12111. * Destroy the camera and release the current resources hold by it.
  12112. */
  12113. dispose(): void;
  12114. /**
  12115. * Gets the current object class name.
  12116. * @return the class name
  12117. */
  12118. getClassName(): string;
  12119. }
  12120. }
  12121. declare module BABYLON {
  12122. /**
  12123. * Represents a gamepad control stick position
  12124. */
  12125. export class StickValues {
  12126. /**
  12127. * The x component of the control stick
  12128. */
  12129. x: number;
  12130. /**
  12131. * The y component of the control stick
  12132. */
  12133. y: number;
  12134. /**
  12135. * Initializes the gamepad x and y control stick values
  12136. * @param x The x component of the gamepad control stick value
  12137. * @param y The y component of the gamepad control stick value
  12138. */
  12139. constructor(
  12140. /**
  12141. * The x component of the control stick
  12142. */
  12143. x: number,
  12144. /**
  12145. * The y component of the control stick
  12146. */
  12147. y: number);
  12148. }
  12149. /**
  12150. * An interface which manages callbacks for gamepad button changes
  12151. */
  12152. export interface GamepadButtonChanges {
  12153. /**
  12154. * Called when a gamepad has been changed
  12155. */
  12156. changed: boolean;
  12157. /**
  12158. * Called when a gamepad press event has been triggered
  12159. */
  12160. pressChanged: boolean;
  12161. /**
  12162. * Called when a touch event has been triggered
  12163. */
  12164. touchChanged: boolean;
  12165. /**
  12166. * Called when a value has changed
  12167. */
  12168. valueChanged: boolean;
  12169. }
  12170. /**
  12171. * Represents a gamepad
  12172. */
  12173. export class Gamepad {
  12174. /**
  12175. * The id of the gamepad
  12176. */
  12177. id: string;
  12178. /**
  12179. * The index of the gamepad
  12180. */
  12181. index: number;
  12182. /**
  12183. * The browser gamepad
  12184. */
  12185. browserGamepad: any;
  12186. /**
  12187. * Specifies what type of gamepad this represents
  12188. */
  12189. type: number;
  12190. private _leftStick;
  12191. private _rightStick;
  12192. /** @hidden */
  12193. _isConnected: boolean;
  12194. private _leftStickAxisX;
  12195. private _leftStickAxisY;
  12196. private _rightStickAxisX;
  12197. private _rightStickAxisY;
  12198. /**
  12199. * Triggered when the left control stick has been changed
  12200. */
  12201. private _onleftstickchanged;
  12202. /**
  12203. * Triggered when the right control stick has been changed
  12204. */
  12205. private _onrightstickchanged;
  12206. /**
  12207. * Represents a gamepad controller
  12208. */
  12209. static GAMEPAD: number;
  12210. /**
  12211. * Represents a generic controller
  12212. */
  12213. static GENERIC: number;
  12214. /**
  12215. * Represents an XBox controller
  12216. */
  12217. static XBOX: number;
  12218. /**
  12219. * Represents a pose-enabled controller
  12220. */
  12221. static POSE_ENABLED: number;
  12222. /**
  12223. * Represents an Dual Shock controller
  12224. */
  12225. static DUALSHOCK: number;
  12226. /**
  12227. * Specifies whether the left control stick should be Y-inverted
  12228. */
  12229. protected _invertLeftStickY: boolean;
  12230. /**
  12231. * Specifies if the gamepad has been connected
  12232. */
  12233. readonly isConnected: boolean;
  12234. /**
  12235. * Initializes the gamepad
  12236. * @param id The id of the gamepad
  12237. * @param index The index of the gamepad
  12238. * @param browserGamepad The browser gamepad
  12239. * @param leftStickX The x component of the left joystick
  12240. * @param leftStickY The y component of the left joystick
  12241. * @param rightStickX The x component of the right joystick
  12242. * @param rightStickY The y component of the right joystick
  12243. */
  12244. constructor(
  12245. /**
  12246. * The id of the gamepad
  12247. */
  12248. id: string,
  12249. /**
  12250. * The index of the gamepad
  12251. */
  12252. index: number,
  12253. /**
  12254. * The browser gamepad
  12255. */
  12256. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12257. /**
  12258. * Callback triggered when the left joystick has changed
  12259. * @param callback
  12260. */
  12261. onleftstickchanged(callback: (values: StickValues) => void): void;
  12262. /**
  12263. * Callback triggered when the right joystick has changed
  12264. * @param callback
  12265. */
  12266. onrightstickchanged(callback: (values: StickValues) => void): void;
  12267. /**
  12268. * Gets the left joystick
  12269. */
  12270. /**
  12271. * Sets the left joystick values
  12272. */
  12273. leftStick: StickValues;
  12274. /**
  12275. * Gets the right joystick
  12276. */
  12277. /**
  12278. * Sets the right joystick value
  12279. */
  12280. rightStick: StickValues;
  12281. /**
  12282. * Updates the gamepad joystick positions
  12283. */
  12284. update(): void;
  12285. /**
  12286. * Disposes the gamepad
  12287. */
  12288. dispose(): void;
  12289. }
  12290. /**
  12291. * Represents a generic gamepad
  12292. */
  12293. export class GenericPad extends Gamepad {
  12294. private _buttons;
  12295. private _onbuttondown;
  12296. private _onbuttonup;
  12297. /**
  12298. * Observable triggered when a button has been pressed
  12299. */
  12300. onButtonDownObservable: Observable<number>;
  12301. /**
  12302. * Observable triggered when a button has been released
  12303. */
  12304. onButtonUpObservable: Observable<number>;
  12305. /**
  12306. * Callback triggered when a button has been pressed
  12307. * @param callback Called when a button has been pressed
  12308. */
  12309. onbuttondown(callback: (buttonPressed: number) => void): void;
  12310. /**
  12311. * Callback triggered when a button has been released
  12312. * @param callback Called when a button has been released
  12313. */
  12314. onbuttonup(callback: (buttonReleased: number) => void): void;
  12315. /**
  12316. * Initializes the generic gamepad
  12317. * @param id The id of the generic gamepad
  12318. * @param index The index of the generic gamepad
  12319. * @param browserGamepad The browser gamepad
  12320. */
  12321. constructor(id: string, index: number, browserGamepad: any);
  12322. private _setButtonValue;
  12323. /**
  12324. * Updates the generic gamepad
  12325. */
  12326. update(): void;
  12327. /**
  12328. * Disposes the generic gamepad
  12329. */
  12330. dispose(): void;
  12331. }
  12332. }
  12333. declare module BABYLON {
  12334. interface Engine {
  12335. /**
  12336. * Creates a raw texture
  12337. * @param data defines the data to store in the texture
  12338. * @param width defines the width of the texture
  12339. * @param height defines the height of the texture
  12340. * @param format defines the format of the data
  12341. * @param generateMipMaps defines if the engine should generate the mip levels
  12342. * @param invertY defines if data must be stored with Y axis inverted
  12343. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12344. * @param compression defines the compression used (null by default)
  12345. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12346. * @returns the raw texture inside an InternalTexture
  12347. */
  12348. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12349. /**
  12350. * Update a raw texture
  12351. * @param texture defines the texture to update
  12352. * @param data defines the data to store in the texture
  12353. * @param format defines the format of the data
  12354. * @param invertY defines if data must be stored with Y axis inverted
  12355. */
  12356. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12357. /**
  12358. * Update a raw texture
  12359. * @param texture defines the texture to update
  12360. * @param data defines the data to store in the texture
  12361. * @param format defines the format of the data
  12362. * @param invertY defines if data must be stored with Y axis inverted
  12363. * @param compression defines the compression used (null by default)
  12364. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12365. */
  12366. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12367. /**
  12368. * Creates a new raw cube texture
  12369. * @param data defines the array of data to use to create each face
  12370. * @param size defines the size of the textures
  12371. * @param format defines the format of the data
  12372. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12373. * @param generateMipMaps defines if the engine should generate the mip levels
  12374. * @param invertY defines if data must be stored with Y axis inverted
  12375. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12376. * @param compression defines the compression used (null by default)
  12377. * @returns the cube texture as an InternalTexture
  12378. */
  12379. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12380. /**
  12381. * Update a raw cube texture
  12382. * @param texture defines the texture to udpdate
  12383. * @param data defines the data to store
  12384. * @param format defines the data format
  12385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12386. * @param invertY defines if data must be stored with Y axis inverted
  12387. */
  12388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12389. /**
  12390. * Update a raw cube texture
  12391. * @param texture defines the texture to udpdate
  12392. * @param data defines the data to store
  12393. * @param format defines the data format
  12394. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12395. * @param invertY defines if data must be stored with Y axis inverted
  12396. * @param compression defines the compression used (null by default)
  12397. */
  12398. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12399. /**
  12400. * Update a raw cube texture
  12401. * @param texture defines the texture to udpdate
  12402. * @param data defines the data to store
  12403. * @param format defines the data format
  12404. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12405. * @param invertY defines if data must be stored with Y axis inverted
  12406. * @param compression defines the compression used (null by default)
  12407. * @param level defines which level of the texture to update
  12408. */
  12409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12410. /**
  12411. * Creates a new raw cube texture from a specified url
  12412. * @param url defines the url where the data is located
  12413. * @param scene defines the current scene
  12414. * @param size defines the size of the textures
  12415. * @param format defines the format of the data
  12416. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12417. * @param noMipmap defines if the engine should avoid generating the mip levels
  12418. * @param callback defines a callback used to extract texture data from loaded data
  12419. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12420. * @param onLoad defines a callback called when texture is loaded
  12421. * @param onError defines a callback called if there is an error
  12422. * @returns the cube texture as an InternalTexture
  12423. */
  12424. 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;
  12425. /**
  12426. * Creates a new raw cube texture from a specified url
  12427. * @param url defines the url where the data is located
  12428. * @param scene defines the current scene
  12429. * @param size defines the size of the textures
  12430. * @param format defines the format of the data
  12431. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12432. * @param noMipmap defines if the engine should avoid generating the mip levels
  12433. * @param callback defines a callback used to extract texture data from loaded data
  12434. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12435. * @param onLoad defines a callback called when texture is loaded
  12436. * @param onError defines a callback called if there is an error
  12437. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @returns the cube texture as an InternalTexture
  12440. */
  12441. 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;
  12442. /**
  12443. * Creates a new raw 3D texture
  12444. * @param data defines the data used to create the texture
  12445. * @param width defines the width of the texture
  12446. * @param height defines the height of the texture
  12447. * @param depth defines the depth of the texture
  12448. * @param format defines the format of the texture
  12449. * @param generateMipMaps defines if the engine must generate mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compressed used (can be null)
  12453. * @param textureType defines the compressed used (can be null)
  12454. * @returns a new raw 3D texture (stored in an InternalTexture)
  12455. */
  12456. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12457. /**
  12458. * Update a raw 3D texture
  12459. * @param texture defines the texture to update
  12460. * @param data defines the data to store
  12461. * @param format defines the data format
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw 3D texture
  12467. * @param texture defines the texture to update
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param invertY defines if data must be stored with Y axis inverted
  12471. * @param compression defines the used compression (can be null)
  12472. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12473. */
  12474. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12475. }
  12476. }
  12477. declare module BABYLON {
  12478. /**
  12479. * Raw texture can help creating a texture directly from an array of data.
  12480. * This can be super useful if you either get the data from an uncompressed source or
  12481. * if you wish to create your texture pixel by pixel.
  12482. */
  12483. export class RawTexture extends Texture {
  12484. /**
  12485. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12486. */
  12487. format: number;
  12488. private _engine;
  12489. /**
  12490. * Instantiates a new RawTexture.
  12491. * Raw texture can help creating a texture directly from an array of data.
  12492. * This can be super useful if you either get the data from an uncompressed source or
  12493. * if you wish to create your texture pixel by pixel.
  12494. * @param data define the array of data to use to create the texture
  12495. * @param width define the width of the texture
  12496. * @param height define the height of the texture
  12497. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12498. * @param scene define the scene the texture belongs to
  12499. * @param generateMipMaps define whether mip maps should be generated or not
  12500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12502. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12503. */
  12504. constructor(data: ArrayBufferView, width: number, height: number,
  12505. /**
  12506. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12507. */
  12508. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12509. /**
  12510. * Updates the texture underlying data.
  12511. * @param data Define the new data of the texture
  12512. */
  12513. update(data: ArrayBufferView): void;
  12514. /**
  12515. * Creates a luminance texture from some data.
  12516. * @param data Define the texture data
  12517. * @param width Define the width of the texture
  12518. * @param height Define the height of the texture
  12519. * @param scene Define the scene the texture belongs to
  12520. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12521. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12522. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12523. * @returns the luminance texture
  12524. */
  12525. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12526. /**
  12527. * Creates a luminance alpha texture from some data.
  12528. * @param data Define the texture data
  12529. * @param width Define the width of the texture
  12530. * @param height Define the height of the texture
  12531. * @param scene Define the scene the texture belongs to
  12532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12535. * @returns the luminance alpha texture
  12536. */
  12537. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12538. /**
  12539. * Creates an alpha texture from some data.
  12540. * @param data Define the texture data
  12541. * @param width Define the width of the texture
  12542. * @param height Define the height of the texture
  12543. * @param scene Define the scene the texture belongs to
  12544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12547. * @returns the alpha texture
  12548. */
  12549. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12550. /**
  12551. * Creates a RGB texture from some data.
  12552. * @param data Define the texture data
  12553. * @param width Define the width of the texture
  12554. * @param height Define the height of the texture
  12555. * @param scene Define the scene the texture belongs to
  12556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12559. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12560. * @returns the RGB alpha texture
  12561. */
  12562. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12563. /**
  12564. * Creates a RGBA texture from some data.
  12565. * @param data Define the texture data
  12566. * @param width Define the width of the texture
  12567. * @param height Define the height of the texture
  12568. * @param scene Define the scene the texture belongs to
  12569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12572. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12573. * @returns the RGBA texture
  12574. */
  12575. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12576. /**
  12577. * Creates a R texture from some data.
  12578. * @param data Define the texture data
  12579. * @param width Define the width of the texture
  12580. * @param height Define the height of the texture
  12581. * @param scene Define the scene the texture belongs to
  12582. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12583. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12584. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12585. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12586. * @returns the R texture
  12587. */
  12588. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12589. }
  12590. }
  12591. declare module BABYLON {
  12592. /**
  12593. * Interface for the size containing width and height
  12594. */
  12595. export interface ISize {
  12596. /**
  12597. * Width
  12598. */
  12599. width: number;
  12600. /**
  12601. * Heighht
  12602. */
  12603. height: number;
  12604. }
  12605. /**
  12606. * Size containing widht and height
  12607. */
  12608. export class Size implements ISize {
  12609. /**
  12610. * Width
  12611. */
  12612. width: number;
  12613. /**
  12614. * Height
  12615. */
  12616. height: number;
  12617. /**
  12618. * Creates a Size object from the given width and height (floats).
  12619. * @param width width of the new size
  12620. * @param height height of the new size
  12621. */
  12622. constructor(width: number, height: number);
  12623. /**
  12624. * Returns a string with the Size width and height
  12625. * @returns a string with the Size width and height
  12626. */
  12627. toString(): string;
  12628. /**
  12629. * "Size"
  12630. * @returns the string "Size"
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Returns the Size hash code.
  12635. * @returns a hash code for a unique width and height
  12636. */
  12637. getHashCode(): number;
  12638. /**
  12639. * Updates the current size from the given one.
  12640. * @param src the given size
  12641. */
  12642. copyFrom(src: Size): void;
  12643. /**
  12644. * Updates in place the current Size from the given floats.
  12645. * @param width width of the new size
  12646. * @param height height of the new size
  12647. * @returns the updated Size.
  12648. */
  12649. copyFromFloats(width: number, height: number): Size;
  12650. /**
  12651. * Updates in place the current Size from the given floats.
  12652. * @param width width to set
  12653. * @param height height to set
  12654. * @returns the updated Size.
  12655. */
  12656. set(width: number, height: number): Size;
  12657. /**
  12658. * Multiplies the width and height by numbers
  12659. * @param w factor to multiple the width by
  12660. * @param h factor to multiple the height by
  12661. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12662. */
  12663. multiplyByFloats(w: number, h: number): Size;
  12664. /**
  12665. * Clones the size
  12666. * @returns a new Size copied from the given one.
  12667. */
  12668. clone(): Size;
  12669. /**
  12670. * True if the current Size and the given one width and height are strictly equal.
  12671. * @param other the other size to compare against
  12672. * @returns True if the current Size and the given one width and height are strictly equal.
  12673. */
  12674. equals(other: Size): boolean;
  12675. /**
  12676. * The surface of the Size : width * height (float).
  12677. */
  12678. readonly surface: number;
  12679. /**
  12680. * Create a new size of zero
  12681. * @returns a new Size set to (0.0, 0.0)
  12682. */
  12683. static Zero(): Size;
  12684. /**
  12685. * Sums the width and height of two sizes
  12686. * @param otherSize size to add to this size
  12687. * @returns a new Size set as the addition result of the current Size and the given one.
  12688. */
  12689. add(otherSize: Size): Size;
  12690. /**
  12691. * Subtracts the width and height of two
  12692. * @param otherSize size to subtract to this size
  12693. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12694. */
  12695. subtract(otherSize: Size): Size;
  12696. /**
  12697. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12698. * @param start starting size to lerp between
  12699. * @param end end size to lerp between
  12700. * @param amount amount to lerp between the start and end values
  12701. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12702. */
  12703. static Lerp(start: Size, end: Size, amount: number): Size;
  12704. }
  12705. }
  12706. declare module BABYLON {
  12707. /**
  12708. * Defines a runtime animation
  12709. */
  12710. export class RuntimeAnimation {
  12711. private _events;
  12712. /**
  12713. * The current frame of the runtime animation
  12714. */
  12715. private _currentFrame;
  12716. /**
  12717. * The animation used by the runtime animation
  12718. */
  12719. private _animation;
  12720. /**
  12721. * The target of the runtime animation
  12722. */
  12723. private _target;
  12724. /**
  12725. * The initiating animatable
  12726. */
  12727. private _host;
  12728. /**
  12729. * The original value of the runtime animation
  12730. */
  12731. private _originalValue;
  12732. /**
  12733. * The original blend value of the runtime animation
  12734. */
  12735. private _originalBlendValue;
  12736. /**
  12737. * The offsets cache of the runtime animation
  12738. */
  12739. private _offsetsCache;
  12740. /**
  12741. * The high limits cache of the runtime animation
  12742. */
  12743. private _highLimitsCache;
  12744. /**
  12745. * Specifies if the runtime animation has been stopped
  12746. */
  12747. private _stopped;
  12748. /**
  12749. * The blending factor of the runtime animation
  12750. */
  12751. private _blendingFactor;
  12752. /**
  12753. * The BabylonJS scene
  12754. */
  12755. private _scene;
  12756. /**
  12757. * The current value of the runtime animation
  12758. */
  12759. private _currentValue;
  12760. /** @hidden */
  12761. _animationState: _IAnimationState;
  12762. /**
  12763. * The active target of the runtime animation
  12764. */
  12765. private _activeTargets;
  12766. private _currentActiveTarget;
  12767. private _directTarget;
  12768. /**
  12769. * The target path of the runtime animation
  12770. */
  12771. private _targetPath;
  12772. /**
  12773. * The weight of the runtime animation
  12774. */
  12775. private _weight;
  12776. /**
  12777. * The ratio offset of the runtime animation
  12778. */
  12779. private _ratioOffset;
  12780. /**
  12781. * The previous delay of the runtime animation
  12782. */
  12783. private _previousDelay;
  12784. /**
  12785. * The previous ratio of the runtime animation
  12786. */
  12787. private _previousRatio;
  12788. private _enableBlending;
  12789. private _keys;
  12790. private _minFrame;
  12791. private _maxFrame;
  12792. private _minValue;
  12793. private _maxValue;
  12794. private _targetIsArray;
  12795. /**
  12796. * Gets the current frame of the runtime animation
  12797. */
  12798. readonly currentFrame: number;
  12799. /**
  12800. * Gets the weight of the runtime animation
  12801. */
  12802. readonly weight: number;
  12803. /**
  12804. * Gets the current value of the runtime animation
  12805. */
  12806. readonly currentValue: any;
  12807. /**
  12808. * Gets the target path of the runtime animation
  12809. */
  12810. readonly targetPath: string;
  12811. /**
  12812. * Gets the actual target of the runtime animation
  12813. */
  12814. readonly target: any;
  12815. /** @hidden */
  12816. _onLoop: () => void;
  12817. /**
  12818. * Create a new RuntimeAnimation object
  12819. * @param target defines the target of the animation
  12820. * @param animation defines the source animation object
  12821. * @param scene defines the hosting scene
  12822. * @param host defines the initiating Animatable
  12823. */
  12824. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12825. private _preparePath;
  12826. /**
  12827. * Gets the animation from the runtime animation
  12828. */
  12829. readonly animation: Animation;
  12830. /**
  12831. * Resets the runtime animation to the beginning
  12832. * @param restoreOriginal defines whether to restore the target property to the original value
  12833. */
  12834. reset(restoreOriginal?: boolean): void;
  12835. /**
  12836. * Specifies if the runtime animation is stopped
  12837. * @returns Boolean specifying if the runtime animation is stopped
  12838. */
  12839. isStopped(): boolean;
  12840. /**
  12841. * Disposes of the runtime animation
  12842. */
  12843. dispose(): void;
  12844. /**
  12845. * Apply the interpolated value to the target
  12846. * @param currentValue defines the value computed by the animation
  12847. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12848. */
  12849. setValue(currentValue: any, weight: number): void;
  12850. private _getOriginalValues;
  12851. private _setValue;
  12852. /**
  12853. * Gets the loop pmode of the runtime animation
  12854. * @returns Loop Mode
  12855. */
  12856. private _getCorrectLoopMode;
  12857. /**
  12858. * Move the current animation to a given frame
  12859. * @param frame defines the frame to move to
  12860. */
  12861. goToFrame(frame: number): void;
  12862. /**
  12863. * @hidden Internal use only
  12864. */
  12865. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12866. /**
  12867. * Execute the current animation
  12868. * @param delay defines the delay to add to the current frame
  12869. * @param from defines the lower bound of the animation range
  12870. * @param to defines the upper bound of the animation range
  12871. * @param loop defines if the current animation must loop
  12872. * @param speedRatio defines the current speed ratio
  12873. * @param weight defines the weight of the animation (default is -1 so no weight)
  12874. * @param onLoop optional callback called when animation loops
  12875. * @returns a boolean indicating if the animation is running
  12876. */
  12877. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12878. }
  12879. }
  12880. declare module BABYLON {
  12881. /**
  12882. * Class used to store an actual running animation
  12883. */
  12884. export class Animatable {
  12885. /** defines the target object */
  12886. target: any;
  12887. /** defines the starting frame number (default is 0) */
  12888. fromFrame: number;
  12889. /** defines the ending frame number (default is 100) */
  12890. toFrame: number;
  12891. /** defines if the animation must loop (default is false) */
  12892. loopAnimation: boolean;
  12893. /** defines a callback to call when animation ends if it is not looping */
  12894. onAnimationEnd?: (() => void) | null | undefined;
  12895. /** defines a callback to call when animation loops */
  12896. onAnimationLoop?: (() => void) | null | undefined;
  12897. private _localDelayOffset;
  12898. private _pausedDelay;
  12899. private _runtimeAnimations;
  12900. private _paused;
  12901. private _scene;
  12902. private _speedRatio;
  12903. private _weight;
  12904. private _syncRoot;
  12905. /**
  12906. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12907. * This will only apply for non looping animation (default is true)
  12908. */
  12909. disposeOnEnd: boolean;
  12910. /**
  12911. * Gets a boolean indicating if the animation has started
  12912. */
  12913. animationStarted: boolean;
  12914. /**
  12915. * Observer raised when the animation ends
  12916. */
  12917. onAnimationEndObservable: Observable<Animatable>;
  12918. /**
  12919. * Observer raised when the animation loops
  12920. */
  12921. onAnimationLoopObservable: Observable<Animatable>;
  12922. /**
  12923. * Gets the root Animatable used to synchronize and normalize animations
  12924. */
  12925. readonly syncRoot: Nullable<Animatable>;
  12926. /**
  12927. * Gets the current frame of the first RuntimeAnimation
  12928. * Used to synchronize Animatables
  12929. */
  12930. readonly masterFrame: number;
  12931. /**
  12932. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12933. */
  12934. weight: number;
  12935. /**
  12936. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12937. */
  12938. speedRatio: number;
  12939. /**
  12940. * Creates a new Animatable
  12941. * @param scene defines the hosting scene
  12942. * @param target defines the target object
  12943. * @param fromFrame defines the starting frame number (default is 0)
  12944. * @param toFrame defines the ending frame number (default is 100)
  12945. * @param loopAnimation defines if the animation must loop (default is false)
  12946. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12947. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12948. * @param animations defines a group of animation to add to the new Animatable
  12949. * @param onAnimationLoop defines a callback to call when animation loops
  12950. */
  12951. constructor(scene: Scene,
  12952. /** defines the target object */
  12953. target: any,
  12954. /** defines the starting frame number (default is 0) */
  12955. fromFrame?: number,
  12956. /** defines the ending frame number (default is 100) */
  12957. toFrame?: number,
  12958. /** defines if the animation must loop (default is false) */
  12959. loopAnimation?: boolean, speedRatio?: number,
  12960. /** defines a callback to call when animation ends if it is not looping */
  12961. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12962. /** defines a callback to call when animation loops */
  12963. onAnimationLoop?: (() => void) | null | undefined);
  12964. /**
  12965. * Synchronize and normalize current Animatable with a source Animatable
  12966. * This is useful when using animation weights and when animations are not of the same length
  12967. * @param root defines the root Animatable to synchronize with
  12968. * @returns the current Animatable
  12969. */
  12970. syncWith(root: Animatable): Animatable;
  12971. /**
  12972. * Gets the list of runtime animations
  12973. * @returns an array of RuntimeAnimation
  12974. */
  12975. getAnimations(): RuntimeAnimation[];
  12976. /**
  12977. * Adds more animations to the current animatable
  12978. * @param target defines the target of the animations
  12979. * @param animations defines the new animations to add
  12980. */
  12981. appendAnimations(target: any, animations: Animation[]): void;
  12982. /**
  12983. * Gets the source animation for a specific property
  12984. * @param property defines the propertyu to look for
  12985. * @returns null or the source animation for the given property
  12986. */
  12987. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12988. /**
  12989. * Gets the runtime animation for a specific property
  12990. * @param property defines the propertyu to look for
  12991. * @returns null or the runtime animation for the given property
  12992. */
  12993. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12994. /**
  12995. * Resets the animatable to its original state
  12996. */
  12997. reset(): void;
  12998. /**
  12999. * Allows the animatable to blend with current running animations
  13000. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13001. * @param blendingSpeed defines the blending speed to use
  13002. */
  13003. enableBlending(blendingSpeed: number): void;
  13004. /**
  13005. * Disable animation blending
  13006. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13007. */
  13008. disableBlending(): void;
  13009. /**
  13010. * Jump directly to a given frame
  13011. * @param frame defines the frame to jump to
  13012. */
  13013. goToFrame(frame: number): void;
  13014. /**
  13015. * Pause the animation
  13016. */
  13017. pause(): void;
  13018. /**
  13019. * Restart the animation
  13020. */
  13021. restart(): void;
  13022. private _raiseOnAnimationEnd;
  13023. /**
  13024. * Stop and delete the current animation
  13025. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13026. * @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)
  13027. */
  13028. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13029. /**
  13030. * Wait asynchronously for the animation to end
  13031. * @returns a promise which will be fullfilled when the animation ends
  13032. */
  13033. waitAsync(): Promise<Animatable>;
  13034. /** @hidden */
  13035. _animate(delay: number): boolean;
  13036. }
  13037. interface Scene {
  13038. /** @hidden */
  13039. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13040. /** @hidden */
  13041. _processLateAnimationBindingsForMatrices(holder: {
  13042. totalWeight: number;
  13043. animations: RuntimeAnimation[];
  13044. originalValue: Matrix;
  13045. }): any;
  13046. /** @hidden */
  13047. _processLateAnimationBindingsForQuaternions(holder: {
  13048. totalWeight: number;
  13049. animations: RuntimeAnimation[];
  13050. originalValue: Quaternion;
  13051. }, refQuaternion: Quaternion): Quaternion;
  13052. /** @hidden */
  13053. _processLateAnimationBindings(): void;
  13054. /**
  13055. * Will start the animation sequence of a given target
  13056. * @param target defines the target
  13057. * @param from defines from which frame should animation start
  13058. * @param to defines until which frame should animation run.
  13059. * @param weight defines the weight to apply to the animation (1.0 by default)
  13060. * @param loop defines if the animation loops
  13061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13062. * @param onAnimationEnd defines the function to be executed when the animation ends
  13063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13064. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13065. * @param onAnimationLoop defines the callback to call when an animation loops
  13066. * @returns the animatable object created for this animation
  13067. */
  13068. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13069. /**
  13070. * Will start the animation sequence of a given target
  13071. * @param target defines the target
  13072. * @param from defines from which frame should animation start
  13073. * @param to defines until which frame should animation run.
  13074. * @param loop defines if the animation loops
  13075. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13076. * @param onAnimationEnd defines the function to be executed when the animation ends
  13077. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13078. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13079. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13080. * @param onAnimationLoop defines the callback to call when an animation loops
  13081. * @returns the animatable object created for this animation
  13082. */
  13083. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13084. /**
  13085. * Will start the animation sequence of a given target and its hierarchy
  13086. * @param target defines the target
  13087. * @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.
  13088. * @param from defines from which frame should animation start
  13089. * @param to defines until which frame should animation run.
  13090. * @param loop defines if the animation loops
  13091. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13092. * @param onAnimationEnd defines the function to be executed when the animation ends
  13093. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13094. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13095. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13096. * @param onAnimationLoop defines the callback to call when an animation loops
  13097. * @returns the list of created animatables
  13098. */
  13099. 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[];
  13100. /**
  13101. * Begin a new animation on a given node
  13102. * @param target defines the target where the animation will take place
  13103. * @param animations defines the list of animations to start
  13104. * @param from defines the initial value
  13105. * @param to defines the final value
  13106. * @param loop defines if you want animation to loop (off by default)
  13107. * @param speedRatio defines the speed ratio to apply to all animations
  13108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13109. * @param onAnimationLoop defines the callback to call when an animation loops
  13110. * @returns the list of created animatables
  13111. */
  13112. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13113. /**
  13114. * Begin a new animation on a given node and its hierarchy
  13115. * @param target defines the root node where the animation will take place
  13116. * @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.
  13117. * @param animations defines the list of animations to start
  13118. * @param from defines the initial value
  13119. * @param to defines the final value
  13120. * @param loop defines if you want animation to loop (off by default)
  13121. * @param speedRatio defines the speed ratio to apply to all animations
  13122. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13123. * @param onAnimationLoop defines the callback to call when an animation loops
  13124. * @returns the list of animatables created for all nodes
  13125. */
  13126. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13127. /**
  13128. * Gets the animatable associated with a specific target
  13129. * @param target defines the target of the animatable
  13130. * @returns the required animatable if found
  13131. */
  13132. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13133. /**
  13134. * Gets all animatables associated with a given target
  13135. * @param target defines the target to look animatables for
  13136. * @returns an array of Animatables
  13137. */
  13138. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13139. /**
  13140. * Stops and removes all animations that have been applied to the scene
  13141. */
  13142. stopAllAnimations(): void;
  13143. }
  13144. interface Bone {
  13145. /**
  13146. * Copy an animation range from another bone
  13147. * @param source defines the source bone
  13148. * @param rangeName defines the range name to copy
  13149. * @param frameOffset defines the frame offset
  13150. * @param rescaleAsRequired defines if rescaling must be applied if required
  13151. * @param skelDimensionsRatio defines the scaling ratio
  13152. * @returns true if operation was successful
  13153. */
  13154. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13155. }
  13156. }
  13157. declare module BABYLON {
  13158. /**
  13159. * Class used to override all child animations of a given target
  13160. */
  13161. export class AnimationPropertiesOverride {
  13162. /**
  13163. * Gets or sets a value indicating if animation blending must be used
  13164. */
  13165. enableBlending: boolean;
  13166. /**
  13167. * Gets or sets the blending speed to use when enableBlending is true
  13168. */
  13169. blendingSpeed: number;
  13170. /**
  13171. * Gets or sets the default loop mode to use
  13172. */
  13173. loopMode: number;
  13174. }
  13175. }
  13176. declare module BABYLON {
  13177. /**
  13178. * Class used to handle skinning animations
  13179. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13180. */
  13181. export class Skeleton implements IAnimatable {
  13182. /** defines the skeleton name */
  13183. name: string;
  13184. /** defines the skeleton Id */
  13185. id: string;
  13186. /**
  13187. * Defines the list of child bones
  13188. */
  13189. bones: Bone[];
  13190. /**
  13191. * Defines an estimate of the dimension of the skeleton at rest
  13192. */
  13193. dimensionsAtRest: Vector3;
  13194. /**
  13195. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13196. */
  13197. needInitialSkinMatrix: boolean;
  13198. /**
  13199. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13200. */
  13201. overrideMesh: Nullable<AbstractMesh>;
  13202. /**
  13203. * Gets the list of animations attached to this skeleton
  13204. */
  13205. animations: Array<Animation>;
  13206. private _scene;
  13207. private _isDirty;
  13208. private _transformMatrices;
  13209. private _transformMatrixTexture;
  13210. private _meshesWithPoseMatrix;
  13211. private _animatables;
  13212. private _identity;
  13213. private _synchronizedWithMesh;
  13214. private _ranges;
  13215. private _lastAbsoluteTransformsUpdateId;
  13216. private _canUseTextureForBones;
  13217. private _uniqueId;
  13218. /** @hidden */
  13219. _numBonesWithLinkedTransformNode: number;
  13220. /** @hidden */
  13221. _hasWaitingData: Nullable<boolean>;
  13222. /**
  13223. * Specifies if the skeleton should be serialized
  13224. */
  13225. doNotSerialize: boolean;
  13226. private _useTextureToStoreBoneMatrices;
  13227. /**
  13228. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13229. * Please note that this option is not available if the hardware does not support it
  13230. */
  13231. useTextureToStoreBoneMatrices: boolean;
  13232. private _animationPropertiesOverride;
  13233. /**
  13234. * Gets or sets the animation properties override
  13235. */
  13236. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13237. /**
  13238. * List of inspectable custom properties (used by the Inspector)
  13239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13240. */
  13241. inspectableCustomProperties: IInspectable[];
  13242. /**
  13243. * An observable triggered before computing the skeleton's matrices
  13244. */
  13245. onBeforeComputeObservable: Observable<Skeleton>;
  13246. /**
  13247. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13248. */
  13249. readonly isUsingTextureForMatrices: boolean;
  13250. /**
  13251. * Gets the unique ID of this skeleton
  13252. */
  13253. readonly uniqueId: number;
  13254. /**
  13255. * Creates a new skeleton
  13256. * @param name defines the skeleton name
  13257. * @param id defines the skeleton Id
  13258. * @param scene defines the hosting scene
  13259. */
  13260. constructor(
  13261. /** defines the skeleton name */
  13262. name: string,
  13263. /** defines the skeleton Id */
  13264. id: string, scene: Scene);
  13265. /**
  13266. * Gets the current object class name.
  13267. * @return the class name
  13268. */
  13269. getClassName(): string;
  13270. /**
  13271. * Returns an array containing the root bones
  13272. * @returns an array containing the root bones
  13273. */
  13274. getChildren(): Array<Bone>;
  13275. /**
  13276. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13277. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13278. * @returns a Float32Array containing matrices data
  13279. */
  13280. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13281. /**
  13282. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13283. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13284. * @returns a raw texture containing the data
  13285. */
  13286. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13287. /**
  13288. * Gets the current hosting scene
  13289. * @returns a scene object
  13290. */
  13291. getScene(): Scene;
  13292. /**
  13293. * Gets a string representing the current skeleton data
  13294. * @param fullDetails defines a boolean indicating if we want a verbose version
  13295. * @returns a string representing the current skeleton data
  13296. */
  13297. toString(fullDetails?: boolean): string;
  13298. /**
  13299. * Get bone's index searching by name
  13300. * @param name defines bone's name to search for
  13301. * @return the indice of the bone. Returns -1 if not found
  13302. */
  13303. getBoneIndexByName(name: string): number;
  13304. /**
  13305. * Creater a new animation range
  13306. * @param name defines the name of the range
  13307. * @param from defines the start key
  13308. * @param to defines the end key
  13309. */
  13310. createAnimationRange(name: string, from: number, to: number): void;
  13311. /**
  13312. * Delete a specific animation range
  13313. * @param name defines the name of the range
  13314. * @param deleteFrames defines if frames must be removed as well
  13315. */
  13316. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13317. /**
  13318. * Gets a specific animation range
  13319. * @param name defines the name of the range to look for
  13320. * @returns the requested animation range or null if not found
  13321. */
  13322. getAnimationRange(name: string): Nullable<AnimationRange>;
  13323. /**
  13324. * Gets the list of all animation ranges defined on this skeleton
  13325. * @returns an array
  13326. */
  13327. getAnimationRanges(): Nullable<AnimationRange>[];
  13328. /**
  13329. * Copy animation range from a source skeleton.
  13330. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13331. * @param source defines the source skeleton
  13332. * @param name defines the name of the range to copy
  13333. * @param rescaleAsRequired defines if rescaling must be applied if required
  13334. * @returns true if operation was successful
  13335. */
  13336. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13337. /**
  13338. * Forces the skeleton to go to rest pose
  13339. */
  13340. returnToRest(): void;
  13341. private _getHighestAnimationFrame;
  13342. /**
  13343. * Begin a specific animation range
  13344. * @param name defines the name of the range to start
  13345. * @param loop defines if looping must be turned on (false by default)
  13346. * @param speedRatio defines the speed ratio to apply (1 by default)
  13347. * @param onAnimationEnd defines a callback which will be called when animation will end
  13348. * @returns a new animatable
  13349. */
  13350. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13351. /** @hidden */
  13352. _markAsDirty(): void;
  13353. /** @hidden */
  13354. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13355. /** @hidden */
  13356. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13357. private _computeTransformMatrices;
  13358. /**
  13359. * Build all resources required to render a skeleton
  13360. */
  13361. prepare(): void;
  13362. /**
  13363. * Gets the list of animatables currently running for this skeleton
  13364. * @returns an array of animatables
  13365. */
  13366. getAnimatables(): IAnimatable[];
  13367. /**
  13368. * Clone the current skeleton
  13369. * @param name defines the name of the new skeleton
  13370. * @param id defines the id of the new skeleton
  13371. * @returns the new skeleton
  13372. */
  13373. clone(name: string, id: string): Skeleton;
  13374. /**
  13375. * Enable animation blending for this skeleton
  13376. * @param blendingSpeed defines the blending speed to apply
  13377. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13378. */
  13379. enableBlending(blendingSpeed?: number): void;
  13380. /**
  13381. * Releases all resources associated with the current skeleton
  13382. */
  13383. dispose(): void;
  13384. /**
  13385. * Serialize the skeleton in a JSON object
  13386. * @returns a JSON object
  13387. */
  13388. serialize(): any;
  13389. /**
  13390. * Creates a new skeleton from serialized data
  13391. * @param parsedSkeleton defines the serialized data
  13392. * @param scene defines the hosting scene
  13393. * @returns a new skeleton
  13394. */
  13395. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13396. /**
  13397. * Compute all node absolute transforms
  13398. * @param forceUpdate defines if computation must be done even if cache is up to date
  13399. */
  13400. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13401. /**
  13402. * Gets the root pose matrix
  13403. * @returns a matrix
  13404. */
  13405. getPoseMatrix(): Nullable<Matrix>;
  13406. /**
  13407. * Sorts bones per internal index
  13408. */
  13409. sortBones(): void;
  13410. private _sortBones;
  13411. }
  13412. }
  13413. declare module BABYLON {
  13414. /**
  13415. * Class used to store bone information
  13416. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13417. */
  13418. export class Bone extends Node {
  13419. /**
  13420. * defines the bone name
  13421. */
  13422. name: string;
  13423. private static _tmpVecs;
  13424. private static _tmpQuat;
  13425. private static _tmpMats;
  13426. /**
  13427. * Gets the list of child bones
  13428. */
  13429. children: Bone[];
  13430. /** Gets the animations associated with this bone */
  13431. animations: Animation[];
  13432. /**
  13433. * Gets or sets bone length
  13434. */
  13435. length: number;
  13436. /**
  13437. * @hidden Internal only
  13438. * Set this value to map this bone to a different index in the transform matrices
  13439. * Set this value to -1 to exclude the bone from the transform matrices
  13440. */
  13441. _index: Nullable<number>;
  13442. private _skeleton;
  13443. private _localMatrix;
  13444. private _restPose;
  13445. private _baseMatrix;
  13446. private _absoluteTransform;
  13447. private _invertedAbsoluteTransform;
  13448. private _parent;
  13449. private _scalingDeterminant;
  13450. private _worldTransform;
  13451. private _localScaling;
  13452. private _localRotation;
  13453. private _localPosition;
  13454. private _needToDecompose;
  13455. private _needToCompose;
  13456. /** @hidden */
  13457. _linkedTransformNode: Nullable<TransformNode>;
  13458. /** @hidden */
  13459. _waitingTransformNodeId: Nullable<string>;
  13460. /** @hidden */
  13461. /** @hidden */
  13462. _matrix: Matrix;
  13463. /**
  13464. * Create a new bone
  13465. * @param name defines the bone name
  13466. * @param skeleton defines the parent skeleton
  13467. * @param parentBone defines the parent (can be null if the bone is the root)
  13468. * @param localMatrix defines the local matrix
  13469. * @param restPose defines the rest pose matrix
  13470. * @param baseMatrix defines the base matrix
  13471. * @param index defines index of the bone in the hiearchy
  13472. */
  13473. constructor(
  13474. /**
  13475. * defines the bone name
  13476. */
  13477. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13478. /**
  13479. * Gets the current object class name.
  13480. * @return the class name
  13481. */
  13482. getClassName(): string;
  13483. /**
  13484. * Gets the parent skeleton
  13485. * @returns a skeleton
  13486. */
  13487. getSkeleton(): Skeleton;
  13488. /**
  13489. * Gets parent bone
  13490. * @returns a bone or null if the bone is the root of the bone hierarchy
  13491. */
  13492. getParent(): Nullable<Bone>;
  13493. /**
  13494. * Returns an array containing the root bones
  13495. * @returns an array containing the root bones
  13496. */
  13497. getChildren(): Array<Bone>;
  13498. /**
  13499. * Sets the parent bone
  13500. * @param parent defines the parent (can be null if the bone is the root)
  13501. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13502. */
  13503. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13504. /**
  13505. * Gets the local matrix
  13506. * @returns a matrix
  13507. */
  13508. getLocalMatrix(): Matrix;
  13509. /**
  13510. * Gets the base matrix (initial matrix which remains unchanged)
  13511. * @returns a matrix
  13512. */
  13513. getBaseMatrix(): Matrix;
  13514. /**
  13515. * Gets the rest pose matrix
  13516. * @returns a matrix
  13517. */
  13518. getRestPose(): Matrix;
  13519. /**
  13520. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13521. */
  13522. getWorldMatrix(): Matrix;
  13523. /**
  13524. * Sets the local matrix to rest pose matrix
  13525. */
  13526. returnToRest(): void;
  13527. /**
  13528. * Gets the inverse of the absolute transform matrix.
  13529. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13530. * @returns a matrix
  13531. */
  13532. getInvertedAbsoluteTransform(): Matrix;
  13533. /**
  13534. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13535. * @returns a matrix
  13536. */
  13537. getAbsoluteTransform(): Matrix;
  13538. /**
  13539. * Links with the given transform node.
  13540. * The local matrix of this bone is copied from the transform node every frame.
  13541. * @param transformNode defines the transform node to link to
  13542. */
  13543. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13544. /**
  13545. * Gets the node used to drive the bone's transformation
  13546. * @returns a transform node or null
  13547. */
  13548. getTransformNode(): Nullable<TransformNode>;
  13549. /** Gets or sets current position (in local space) */
  13550. position: Vector3;
  13551. /** Gets or sets current rotation (in local space) */
  13552. rotation: Vector3;
  13553. /** Gets or sets current rotation quaternion (in local space) */
  13554. rotationQuaternion: Quaternion;
  13555. /** Gets or sets current scaling (in local space) */
  13556. scaling: Vector3;
  13557. /**
  13558. * Gets the animation properties override
  13559. */
  13560. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13561. private _decompose;
  13562. private _compose;
  13563. /**
  13564. * Update the base and local matrices
  13565. * @param matrix defines the new base or local matrix
  13566. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13567. * @param updateLocalMatrix defines if the local matrix should be updated
  13568. */
  13569. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13570. /** @hidden */
  13571. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13572. /**
  13573. * Flag the bone as dirty (Forcing it to update everything)
  13574. */
  13575. markAsDirty(): void;
  13576. /** @hidden */
  13577. _markAsDirtyAndCompose(): void;
  13578. private _markAsDirtyAndDecompose;
  13579. /**
  13580. * Translate the bone in local or world space
  13581. * @param vec The amount to translate the bone
  13582. * @param space The space that the translation is in
  13583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13584. */
  13585. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13586. /**
  13587. * Set the postion of the bone in local or world space
  13588. * @param position The position to set the bone
  13589. * @param space The space that the position is in
  13590. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13591. */
  13592. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13593. /**
  13594. * Set the absolute position of the bone (world space)
  13595. * @param position The position to set the bone
  13596. * @param mesh The mesh that this bone is attached to
  13597. */
  13598. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13599. /**
  13600. * Scale the bone on the x, y and z axes (in local space)
  13601. * @param x The amount to scale the bone on the x axis
  13602. * @param y The amount to scale the bone on the y axis
  13603. * @param z The amount to scale the bone on the z axis
  13604. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13605. */
  13606. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13607. /**
  13608. * Set the bone scaling in local space
  13609. * @param scale defines the scaling vector
  13610. */
  13611. setScale(scale: Vector3): void;
  13612. /**
  13613. * Gets the current scaling in local space
  13614. * @returns the current scaling vector
  13615. */
  13616. getScale(): Vector3;
  13617. /**
  13618. * Gets the current scaling in local space and stores it in a target vector
  13619. * @param result defines the target vector
  13620. */
  13621. getScaleToRef(result: Vector3): void;
  13622. /**
  13623. * Set the yaw, pitch, and roll of the bone in local or world space
  13624. * @param yaw The rotation of the bone on the y axis
  13625. * @param pitch The rotation of the bone on the x axis
  13626. * @param roll The rotation of the bone on the z axis
  13627. * @param space The space that the axes of rotation are in
  13628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13629. */
  13630. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13631. /**
  13632. * Add a rotation to the bone on an axis in local or world space
  13633. * @param axis The axis to rotate the bone on
  13634. * @param amount The amount to rotate the bone
  13635. * @param space The space that the axis is in
  13636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13637. */
  13638. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13639. /**
  13640. * Set the rotation of the bone to a particular axis angle in local or world space
  13641. * @param axis The axis to rotate the bone on
  13642. * @param angle The angle that the bone should be rotated to
  13643. * @param space The space that the axis is in
  13644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13645. */
  13646. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13647. /**
  13648. * Set the euler rotation of the bone in local of world space
  13649. * @param rotation The euler rotation that the bone should be set to
  13650. * @param space The space that the rotation is in
  13651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13652. */
  13653. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13654. /**
  13655. * Set the quaternion rotation of the bone in local of world space
  13656. * @param quat The quaternion rotation that the bone should be set to
  13657. * @param space The space that the rotation is in
  13658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13659. */
  13660. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13661. /**
  13662. * Set the rotation matrix of the bone in local of world space
  13663. * @param rotMat The rotation matrix that the bone should be set to
  13664. * @param space The space that the rotation is in
  13665. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13666. */
  13667. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13668. private _rotateWithMatrix;
  13669. private _getNegativeRotationToRef;
  13670. /**
  13671. * Get the position of the bone in local or world space
  13672. * @param space The space that the returned position is in
  13673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13674. * @returns The position of the bone
  13675. */
  13676. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13677. /**
  13678. * Copy the position of the bone to a vector3 in local or world space
  13679. * @param space The space that the returned position is in
  13680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13681. * @param result The vector3 to copy the position to
  13682. */
  13683. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13684. /**
  13685. * Get the absolute position of the bone (world space)
  13686. * @param mesh The mesh that this bone is attached to
  13687. * @returns The absolute position of the bone
  13688. */
  13689. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13690. /**
  13691. * Copy the absolute position of the bone (world space) to the result param
  13692. * @param mesh The mesh that this bone is attached to
  13693. * @param result The vector3 to copy the absolute position to
  13694. */
  13695. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13696. /**
  13697. * Compute the absolute transforms of this bone and its children
  13698. */
  13699. computeAbsoluteTransforms(): void;
  13700. /**
  13701. * Get the world direction from an axis that is in the local space of the bone
  13702. * @param localAxis The local direction that is used to compute the world direction
  13703. * @param mesh The mesh that this bone is attached to
  13704. * @returns The world direction
  13705. */
  13706. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13707. /**
  13708. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13709. * @param localAxis The local direction that is used to compute the world direction
  13710. * @param mesh The mesh that this bone is attached to
  13711. * @param result The vector3 that the world direction will be copied to
  13712. */
  13713. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13714. /**
  13715. * Get the euler rotation of the bone in local or world space
  13716. * @param space The space that the rotation should be in
  13717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13718. * @returns The euler rotation
  13719. */
  13720. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13721. /**
  13722. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13723. * @param space The space that the rotation should be in
  13724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13725. * @param result The vector3 that the rotation should be copied to
  13726. */
  13727. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13728. /**
  13729. * Get the quaternion rotation of the bone in either local or world space
  13730. * @param space The space that the rotation should be in
  13731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13732. * @returns The quaternion rotation
  13733. */
  13734. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13735. /**
  13736. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13737. * @param space The space that the rotation should be in
  13738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13739. * @param result The quaternion that the rotation should be copied to
  13740. */
  13741. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13742. /**
  13743. * Get the rotation matrix of the bone in local or world space
  13744. * @param space The space that the rotation should be in
  13745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13746. * @returns The rotation matrix
  13747. */
  13748. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13749. /**
  13750. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13751. * @param space The space that the rotation should be in
  13752. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13753. * @param result The quaternion that the rotation should be copied to
  13754. */
  13755. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13756. /**
  13757. * Get the world position of a point that is in the local space of the bone
  13758. * @param position The local position
  13759. * @param mesh The mesh that this bone is attached to
  13760. * @returns The world position
  13761. */
  13762. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13763. /**
  13764. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13765. * @param position The local position
  13766. * @param mesh The mesh that this bone is attached to
  13767. * @param result The vector3 that the world position should be copied to
  13768. */
  13769. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13770. /**
  13771. * Get the local position of a point that is in world space
  13772. * @param position The world position
  13773. * @param mesh The mesh that this bone is attached to
  13774. * @returns The local position
  13775. */
  13776. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13777. /**
  13778. * Get the local position of a point that is in world space and copy it to the result param
  13779. * @param position The world position
  13780. * @param mesh The mesh that this bone is attached to
  13781. * @param result The vector3 that the local position should be copied to
  13782. */
  13783. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13784. }
  13785. }
  13786. declare module BABYLON {
  13787. /**
  13788. * 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.
  13789. * @see https://doc.babylonjs.com/how_to/transformnode
  13790. */
  13791. export class TransformNode extends Node {
  13792. /**
  13793. * Object will not rotate to face the camera
  13794. */
  13795. static BILLBOARDMODE_NONE: number;
  13796. /**
  13797. * Object will rotate to face the camera but only on the x axis
  13798. */
  13799. static BILLBOARDMODE_X: number;
  13800. /**
  13801. * Object will rotate to face the camera but only on the y axis
  13802. */
  13803. static BILLBOARDMODE_Y: number;
  13804. /**
  13805. * Object will rotate to face the camera but only on the z axis
  13806. */
  13807. static BILLBOARDMODE_Z: number;
  13808. /**
  13809. * Object will rotate to face the camera
  13810. */
  13811. static BILLBOARDMODE_ALL: number;
  13812. /**
  13813. * Object will rotate to face the camera's position instead of orientation
  13814. */
  13815. static BILLBOARDMODE_USE_POSITION: number;
  13816. private _forward;
  13817. private _forwardInverted;
  13818. private _up;
  13819. private _right;
  13820. private _rightInverted;
  13821. private _position;
  13822. private _rotation;
  13823. private _rotationQuaternion;
  13824. protected _scaling: Vector3;
  13825. protected _isDirty: boolean;
  13826. private _transformToBoneReferal;
  13827. private _isAbsoluteSynced;
  13828. private _billboardMode;
  13829. /**
  13830. * Gets or sets the billboard mode. Default is 0.
  13831. *
  13832. * | Value | Type | Description |
  13833. * | --- | --- | --- |
  13834. * | 0 | BILLBOARDMODE_NONE | |
  13835. * | 1 | BILLBOARDMODE_X | |
  13836. * | 2 | BILLBOARDMODE_Y | |
  13837. * | 4 | BILLBOARDMODE_Z | |
  13838. * | 7 | BILLBOARDMODE_ALL | |
  13839. *
  13840. */
  13841. billboardMode: number;
  13842. private _preserveParentRotationForBillboard;
  13843. /**
  13844. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13845. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13846. */
  13847. preserveParentRotationForBillboard: boolean;
  13848. /**
  13849. * 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
  13850. */
  13851. scalingDeterminant: number;
  13852. private _infiniteDistance;
  13853. /**
  13854. * Gets or sets the distance of the object to max, often used by skybox
  13855. */
  13856. infiniteDistance: boolean;
  13857. /**
  13858. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13859. * By default the system will update normals to compensate
  13860. */
  13861. ignoreNonUniformScaling: boolean;
  13862. /**
  13863. * 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
  13864. */
  13865. reIntegrateRotationIntoRotationQuaternion: boolean;
  13866. /** @hidden */
  13867. _poseMatrix: Nullable<Matrix>;
  13868. /** @hidden */
  13869. _localMatrix: Matrix;
  13870. private _usePivotMatrix;
  13871. private _absolutePosition;
  13872. private _absoluteScaling;
  13873. private _absoluteRotationQuaternion;
  13874. private _pivotMatrix;
  13875. private _pivotMatrixInverse;
  13876. protected _postMultiplyPivotMatrix: boolean;
  13877. protected _isWorldMatrixFrozen: boolean;
  13878. /** @hidden */
  13879. _indexInSceneTransformNodesArray: number;
  13880. /**
  13881. * An event triggered after the world matrix is updated
  13882. */
  13883. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13884. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13885. /**
  13886. * Gets a string identifying the name of the class
  13887. * @returns "TransformNode" string
  13888. */
  13889. getClassName(): string;
  13890. /**
  13891. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13892. */
  13893. position: Vector3;
  13894. /**
  13895. * 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)).
  13896. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13897. */
  13898. rotation: Vector3;
  13899. /**
  13900. * 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)).
  13901. */
  13902. scaling: Vector3;
  13903. /**
  13904. * 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).
  13905. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13906. */
  13907. rotationQuaternion: Nullable<Quaternion>;
  13908. /**
  13909. * The forward direction of that transform in world space.
  13910. */
  13911. readonly forward: Vector3;
  13912. /**
  13913. * The up direction of that transform in world space.
  13914. */
  13915. readonly up: Vector3;
  13916. /**
  13917. * The right direction of that transform in world space.
  13918. */
  13919. readonly right: Vector3;
  13920. /**
  13921. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13922. * @param matrix the matrix to copy the pose from
  13923. * @returns this TransformNode.
  13924. */
  13925. updatePoseMatrix(matrix: Matrix): TransformNode;
  13926. /**
  13927. * Returns the mesh Pose matrix.
  13928. * @returns the pose matrix
  13929. */
  13930. getPoseMatrix(): Matrix;
  13931. /** @hidden */
  13932. _isSynchronized(): boolean;
  13933. /** @hidden */
  13934. _initCache(): void;
  13935. /**
  13936. * Flag the transform node as dirty (Forcing it to update everything)
  13937. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13938. * @returns this transform node
  13939. */
  13940. markAsDirty(property: string): TransformNode;
  13941. /**
  13942. * Returns the current mesh absolute position.
  13943. * Returns a Vector3.
  13944. */
  13945. readonly absolutePosition: Vector3;
  13946. /**
  13947. * Returns the current mesh absolute scaling.
  13948. * Returns a Vector3.
  13949. */
  13950. readonly absoluteScaling: Vector3;
  13951. /**
  13952. * Returns the current mesh absolute rotation.
  13953. * Returns a Quaternion.
  13954. */
  13955. readonly absoluteRotationQuaternion: Quaternion;
  13956. /**
  13957. * Sets a new matrix to apply before all other transformation
  13958. * @param matrix defines the transform matrix
  13959. * @returns the current TransformNode
  13960. */
  13961. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13962. /**
  13963. * Sets a new pivot matrix to the current node
  13964. * @param matrix defines the new pivot matrix to use
  13965. * @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
  13966. * @returns the current TransformNode
  13967. */
  13968. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13969. /**
  13970. * Returns the mesh pivot matrix.
  13971. * Default : Identity.
  13972. * @returns the matrix
  13973. */
  13974. getPivotMatrix(): Matrix;
  13975. /**
  13976. * Instantiate (when possible) or clone that node with its hierarchy
  13977. * @param newParent defines the new parent to use for the instance (or clone)
  13978. * @returns an instance (or a clone) of the current node with its hiearchy
  13979. */
  13980. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13981. /**
  13982. * Prevents the World matrix to be computed any longer
  13983. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13984. * @returns the TransformNode.
  13985. */
  13986. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13987. /**
  13988. * Allows back the World matrix computation.
  13989. * @returns the TransformNode.
  13990. */
  13991. unfreezeWorldMatrix(): this;
  13992. /**
  13993. * True if the World matrix has been frozen.
  13994. */
  13995. readonly isWorldMatrixFrozen: boolean;
  13996. /**
  13997. * Retuns the mesh absolute position in the World.
  13998. * @returns a Vector3.
  13999. */
  14000. getAbsolutePosition(): Vector3;
  14001. /**
  14002. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14003. * @param absolutePosition the absolute position to set
  14004. * @returns the TransformNode.
  14005. */
  14006. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14007. /**
  14008. * Sets the mesh position in its local space.
  14009. * @param vector3 the position to set in localspace
  14010. * @returns the TransformNode.
  14011. */
  14012. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14013. /**
  14014. * Returns the mesh position in the local space from the current World matrix values.
  14015. * @returns a new Vector3.
  14016. */
  14017. getPositionExpressedInLocalSpace(): Vector3;
  14018. /**
  14019. * Translates the mesh along the passed Vector3 in its local space.
  14020. * @param vector3 the distance to translate in localspace
  14021. * @returns the TransformNode.
  14022. */
  14023. locallyTranslate(vector3: Vector3): TransformNode;
  14024. private static _lookAtVectorCache;
  14025. /**
  14026. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14027. * @param targetPoint the position (must be in same space as current mesh) to look at
  14028. * @param yawCor optional yaw (y-axis) correction in radians
  14029. * @param pitchCor optional pitch (x-axis) correction in radians
  14030. * @param rollCor optional roll (z-axis) correction in radians
  14031. * @param space the choosen space of the target
  14032. * @returns the TransformNode.
  14033. */
  14034. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14035. /**
  14036. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14037. * This Vector3 is expressed in the World space.
  14038. * @param localAxis axis to rotate
  14039. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14040. */
  14041. getDirection(localAxis: Vector3): Vector3;
  14042. /**
  14043. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14044. * localAxis is expressed in the mesh local space.
  14045. * result is computed in the Wordl space from the mesh World matrix.
  14046. * @param localAxis axis to rotate
  14047. * @param result the resulting transformnode
  14048. * @returns this TransformNode.
  14049. */
  14050. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14051. /**
  14052. * Sets this transform node rotation to the given local axis.
  14053. * @param localAxis the axis in local space
  14054. * @param yawCor optional yaw (y-axis) correction in radians
  14055. * @param pitchCor optional pitch (x-axis) correction in radians
  14056. * @param rollCor optional roll (z-axis) correction in radians
  14057. * @returns this TransformNode
  14058. */
  14059. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14060. /**
  14061. * Sets a new pivot point to the current node
  14062. * @param point defines the new pivot point to use
  14063. * @param space defines if the point is in world or local space (local by default)
  14064. * @returns the current TransformNode
  14065. */
  14066. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14067. /**
  14068. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14069. * @returns the pivot point
  14070. */
  14071. getPivotPoint(): Vector3;
  14072. /**
  14073. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14074. * @param result the vector3 to store the result
  14075. * @returns this TransformNode.
  14076. */
  14077. getPivotPointToRef(result: Vector3): TransformNode;
  14078. /**
  14079. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14080. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14081. */
  14082. getAbsolutePivotPoint(): Vector3;
  14083. /**
  14084. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14085. * @param result vector3 to store the result
  14086. * @returns this TransformNode.
  14087. */
  14088. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14089. /**
  14090. * Defines the passed node as the parent of the current node.
  14091. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14092. * @see https://doc.babylonjs.com/how_to/parenting
  14093. * @param node the node ot set as the parent
  14094. * @returns this TransformNode.
  14095. */
  14096. setParent(node: Nullable<Node>): TransformNode;
  14097. private _nonUniformScaling;
  14098. /**
  14099. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14100. */
  14101. readonly nonUniformScaling: boolean;
  14102. /** @hidden */
  14103. _updateNonUniformScalingState(value: boolean): boolean;
  14104. /**
  14105. * Attach the current TransformNode to another TransformNode associated with a bone
  14106. * @param bone Bone affecting the TransformNode
  14107. * @param affectedTransformNode TransformNode associated with the bone
  14108. * @returns this object
  14109. */
  14110. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14111. /**
  14112. * Detach the transform node if its associated with a bone
  14113. * @returns this object
  14114. */
  14115. detachFromBone(): TransformNode;
  14116. private static _rotationAxisCache;
  14117. /**
  14118. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14119. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14120. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14121. * The passed axis is also normalized.
  14122. * @param axis the axis to rotate around
  14123. * @param amount the amount to rotate in radians
  14124. * @param space Space to rotate in (Default: local)
  14125. * @returns the TransformNode.
  14126. */
  14127. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14128. /**
  14129. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14130. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14131. * The passed axis is also normalized. .
  14132. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14133. * @param point the point to rotate around
  14134. * @param axis the axis to rotate around
  14135. * @param amount the amount to rotate in radians
  14136. * @returns the TransformNode
  14137. */
  14138. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14139. /**
  14140. * Translates the mesh along the axis vector for the passed distance in the given space.
  14141. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14142. * @param axis the axis to translate in
  14143. * @param distance the distance to translate
  14144. * @param space Space to rotate in (Default: local)
  14145. * @returns the TransformNode.
  14146. */
  14147. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14148. /**
  14149. * Adds a rotation step to the mesh current rotation.
  14150. * x, y, z are Euler angles expressed in radians.
  14151. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14152. * This means this rotation is made in the mesh local space only.
  14153. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14154. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14155. * ```javascript
  14156. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14157. * ```
  14158. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14159. * 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.
  14160. * @param x Rotation to add
  14161. * @param y Rotation to add
  14162. * @param z Rotation to add
  14163. * @returns the TransformNode.
  14164. */
  14165. addRotation(x: number, y: number, z: number): TransformNode;
  14166. /**
  14167. * @hidden
  14168. */
  14169. protected _getEffectiveParent(): Nullable<Node>;
  14170. /**
  14171. * Computes the world matrix of the node
  14172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14173. * @returns the world matrix
  14174. */
  14175. computeWorldMatrix(force?: boolean): Matrix;
  14176. protected _afterComputeWorldMatrix(): void;
  14177. /**
  14178. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14179. * @param func callback function to add
  14180. *
  14181. * @returns the TransformNode.
  14182. */
  14183. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14184. /**
  14185. * Removes a registered callback function.
  14186. * @param func callback function to remove
  14187. * @returns the TransformNode.
  14188. */
  14189. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14190. /**
  14191. * Gets the position of the current mesh in camera space
  14192. * @param camera defines the camera to use
  14193. * @returns a position
  14194. */
  14195. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14196. /**
  14197. * Returns the distance from the mesh to the active camera
  14198. * @param camera defines the camera to use
  14199. * @returns the distance
  14200. */
  14201. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14202. /**
  14203. * Clone the current transform node
  14204. * @param name Name of the new clone
  14205. * @param newParent New parent for the clone
  14206. * @param doNotCloneChildren Do not clone children hierarchy
  14207. * @returns the new transform node
  14208. */
  14209. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14210. /**
  14211. * Serializes the objects information.
  14212. * @param currentSerializationObject defines the object to serialize in
  14213. * @returns the serialized object
  14214. */
  14215. serialize(currentSerializationObject?: any): any;
  14216. /**
  14217. * Returns a new TransformNode object parsed from the source provided.
  14218. * @param parsedTransformNode is the source.
  14219. * @param scene the scne the object belongs to
  14220. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14221. * @returns a new TransformNode object parsed from the source provided.
  14222. */
  14223. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14224. /**
  14225. * Get all child-transformNodes of this node
  14226. * @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
  14227. * @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
  14228. * @returns an array of TransformNode
  14229. */
  14230. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14231. /**
  14232. * Releases resources associated with this transform node.
  14233. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14234. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14235. */
  14236. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14237. /**
  14238. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14239. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14240. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14241. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14242. * @returns the current mesh
  14243. */
  14244. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14245. private _syncAbsoluteScalingAndRotation;
  14246. }
  14247. }
  14248. declare module BABYLON {
  14249. /**
  14250. * Defines the types of pose enabled controllers that are supported
  14251. */
  14252. export enum PoseEnabledControllerType {
  14253. /**
  14254. * HTC Vive
  14255. */
  14256. VIVE = 0,
  14257. /**
  14258. * Oculus Rift
  14259. */
  14260. OCULUS = 1,
  14261. /**
  14262. * Windows mixed reality
  14263. */
  14264. WINDOWS = 2,
  14265. /**
  14266. * Samsung gear VR
  14267. */
  14268. GEAR_VR = 3,
  14269. /**
  14270. * Google Daydream
  14271. */
  14272. DAYDREAM = 4,
  14273. /**
  14274. * Generic
  14275. */
  14276. GENERIC = 5
  14277. }
  14278. /**
  14279. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14280. */
  14281. export interface MutableGamepadButton {
  14282. /**
  14283. * Value of the button/trigger
  14284. */
  14285. value: number;
  14286. /**
  14287. * If the button/trigger is currently touched
  14288. */
  14289. touched: boolean;
  14290. /**
  14291. * If the button/trigger is currently pressed
  14292. */
  14293. pressed: boolean;
  14294. }
  14295. /**
  14296. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14297. * @hidden
  14298. */
  14299. export interface ExtendedGamepadButton extends GamepadButton {
  14300. /**
  14301. * If the button/trigger is currently pressed
  14302. */
  14303. readonly pressed: boolean;
  14304. /**
  14305. * If the button/trigger is currently touched
  14306. */
  14307. readonly touched: boolean;
  14308. /**
  14309. * Value of the button/trigger
  14310. */
  14311. readonly value: number;
  14312. }
  14313. /** @hidden */
  14314. export interface _GamePadFactory {
  14315. /**
  14316. * Returns wether or not the current gamepad can be created for this type of controller.
  14317. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14318. * @returns true if it can be created, otherwise false
  14319. */
  14320. canCreate(gamepadInfo: any): boolean;
  14321. /**
  14322. * Creates a new instance of the Gamepad.
  14323. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14324. * @returns the new gamepad instance
  14325. */
  14326. create(gamepadInfo: any): Gamepad;
  14327. }
  14328. /**
  14329. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14330. */
  14331. export class PoseEnabledControllerHelper {
  14332. /** @hidden */
  14333. static _ControllerFactories: _GamePadFactory[];
  14334. /** @hidden */
  14335. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14336. /**
  14337. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14338. * @param vrGamepad the gamepad to initialized
  14339. * @returns a vr controller of the type the gamepad identified as
  14340. */
  14341. static InitiateController(vrGamepad: any): Gamepad;
  14342. }
  14343. /**
  14344. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14345. */
  14346. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14347. /**
  14348. * If the controller is used in a webXR session
  14349. */
  14350. isXR: boolean;
  14351. private _deviceRoomPosition;
  14352. private _deviceRoomRotationQuaternion;
  14353. /**
  14354. * The device position in babylon space
  14355. */
  14356. devicePosition: Vector3;
  14357. /**
  14358. * The device rotation in babylon space
  14359. */
  14360. deviceRotationQuaternion: Quaternion;
  14361. /**
  14362. * The scale factor of the device in babylon space
  14363. */
  14364. deviceScaleFactor: number;
  14365. /**
  14366. * (Likely devicePosition should be used instead) The device position in its room space
  14367. */
  14368. position: Vector3;
  14369. /**
  14370. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14371. */
  14372. rotationQuaternion: Quaternion;
  14373. /**
  14374. * The type of controller (Eg. Windows mixed reality)
  14375. */
  14376. controllerType: PoseEnabledControllerType;
  14377. protected _calculatedPosition: Vector3;
  14378. private _calculatedRotation;
  14379. /**
  14380. * The raw pose from the device
  14381. */
  14382. rawPose: DevicePose;
  14383. private _trackPosition;
  14384. private _maxRotationDistFromHeadset;
  14385. private _draggedRoomRotation;
  14386. /**
  14387. * @hidden
  14388. */
  14389. _disableTrackPosition(fixedPosition: Vector3): void;
  14390. /**
  14391. * Internal, the mesh attached to the controller
  14392. * @hidden
  14393. */
  14394. _mesh: Nullable<AbstractMesh>;
  14395. private _poseControlledCamera;
  14396. private _leftHandSystemQuaternion;
  14397. /**
  14398. * Internal, matrix used to convert room space to babylon space
  14399. * @hidden
  14400. */
  14401. _deviceToWorld: Matrix;
  14402. /**
  14403. * Node to be used when casting a ray from the controller
  14404. * @hidden
  14405. */
  14406. _pointingPoseNode: Nullable<TransformNode>;
  14407. /**
  14408. * Name of the child mesh that can be used to cast a ray from the controller
  14409. */
  14410. static readonly POINTING_POSE: string;
  14411. /**
  14412. * Creates a new PoseEnabledController from a gamepad
  14413. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14414. */
  14415. constructor(browserGamepad: any);
  14416. private _workingMatrix;
  14417. /**
  14418. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14419. */
  14420. update(): void;
  14421. /**
  14422. * Updates only the pose device and mesh without doing any button event checking
  14423. */
  14424. protected _updatePoseAndMesh(): void;
  14425. /**
  14426. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14427. * @param poseData raw pose fromthe device
  14428. */
  14429. updateFromDevice(poseData: DevicePose): void;
  14430. /**
  14431. * @hidden
  14432. */
  14433. _meshAttachedObservable: Observable<AbstractMesh>;
  14434. /**
  14435. * Attaches a mesh to the controller
  14436. * @param mesh the mesh to be attached
  14437. */
  14438. attachToMesh(mesh: AbstractMesh): void;
  14439. /**
  14440. * Attaches the controllers mesh to a camera
  14441. * @param camera the camera the mesh should be attached to
  14442. */
  14443. attachToPoseControlledCamera(camera: TargetCamera): void;
  14444. /**
  14445. * Disposes of the controller
  14446. */
  14447. dispose(): void;
  14448. /**
  14449. * The mesh that is attached to the controller
  14450. */
  14451. readonly mesh: Nullable<AbstractMesh>;
  14452. /**
  14453. * Gets the ray of the controller in the direction the controller is pointing
  14454. * @param length the length the resulting ray should be
  14455. * @returns a ray in the direction the controller is pointing
  14456. */
  14457. getForwardRay(length?: number): Ray;
  14458. }
  14459. }
  14460. declare module BABYLON {
  14461. /**
  14462. * Defines the WebVRController object that represents controllers tracked in 3D space
  14463. */
  14464. export abstract class WebVRController extends PoseEnabledController {
  14465. /**
  14466. * Internal, the default controller model for the controller
  14467. */
  14468. protected _defaultModel: Nullable<AbstractMesh>;
  14469. /**
  14470. * Fired when the trigger state has changed
  14471. */
  14472. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14473. /**
  14474. * Fired when the main button state has changed
  14475. */
  14476. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14477. /**
  14478. * Fired when the secondary button state has changed
  14479. */
  14480. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14481. /**
  14482. * Fired when the pad state has changed
  14483. */
  14484. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14485. /**
  14486. * Fired when controllers stick values have changed
  14487. */
  14488. onPadValuesChangedObservable: Observable<StickValues>;
  14489. /**
  14490. * Array of button availible on the controller
  14491. */
  14492. protected _buttons: Array<MutableGamepadButton>;
  14493. private _onButtonStateChange;
  14494. /**
  14495. * Fired when a controller button's state has changed
  14496. * @param callback the callback containing the button that was modified
  14497. */
  14498. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14499. /**
  14500. * X and Y axis corresponding to the controllers joystick
  14501. */
  14502. pad: StickValues;
  14503. /**
  14504. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14505. */
  14506. hand: string;
  14507. /**
  14508. * The default controller model for the controller
  14509. */
  14510. readonly defaultModel: Nullable<AbstractMesh>;
  14511. /**
  14512. * Creates a new WebVRController from a gamepad
  14513. * @param vrGamepad the gamepad that the WebVRController should be created from
  14514. */
  14515. constructor(vrGamepad: any);
  14516. /**
  14517. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14518. */
  14519. update(): void;
  14520. /**
  14521. * Function to be called when a button is modified
  14522. */
  14523. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14524. /**
  14525. * Loads a mesh and attaches it to the controller
  14526. * @param scene the scene the mesh should be added to
  14527. * @param meshLoaded callback for when the mesh has been loaded
  14528. */
  14529. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14530. private _setButtonValue;
  14531. private _changes;
  14532. private _checkChanges;
  14533. /**
  14534. * Disposes of th webVRCOntroller
  14535. */
  14536. dispose(): void;
  14537. }
  14538. }
  14539. declare module BABYLON {
  14540. /**
  14541. * The HemisphericLight simulates the ambient environment light,
  14542. * so the passed direction is the light reflection direction, not the incoming direction.
  14543. */
  14544. export class HemisphericLight extends Light {
  14545. /**
  14546. * The groundColor is the light in the opposite direction to the one specified during creation.
  14547. * 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.
  14548. */
  14549. groundColor: Color3;
  14550. /**
  14551. * The light reflection direction, not the incoming direction.
  14552. */
  14553. direction: Vector3;
  14554. /**
  14555. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14556. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14557. * The HemisphericLight can't cast shadows.
  14558. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14559. * @param name The friendly name of the light
  14560. * @param direction The direction of the light reflection
  14561. * @param scene The scene the light belongs to
  14562. */
  14563. constructor(name: string, direction: Vector3, scene: Scene);
  14564. protected _buildUniformLayout(): void;
  14565. /**
  14566. * Returns the string "HemisphericLight".
  14567. * @return The class name
  14568. */
  14569. getClassName(): string;
  14570. /**
  14571. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14572. * Returns the updated direction.
  14573. * @param target The target the direction should point to
  14574. * @return The computed direction
  14575. */
  14576. setDirectionToTarget(target: Vector3): Vector3;
  14577. /**
  14578. * Returns the shadow generator associated to the light.
  14579. * @returns Always null for hemispheric lights because it does not support shadows.
  14580. */
  14581. getShadowGenerator(): Nullable<IShadowGenerator>;
  14582. /**
  14583. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14584. * @param effect The effect to update
  14585. * @param lightIndex The index of the light in the effect to update
  14586. * @returns The hemispheric light
  14587. */
  14588. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14589. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14590. /**
  14591. * Computes the world matrix of the node
  14592. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14593. * @param useWasUpdatedFlag defines a reserved property
  14594. * @returns the world matrix
  14595. */
  14596. computeWorldMatrix(): Matrix;
  14597. /**
  14598. * Returns the integer 3.
  14599. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14600. */
  14601. getTypeID(): number;
  14602. /**
  14603. * Prepares the list of defines specific to the light type.
  14604. * @param defines the list of defines
  14605. * @param lightIndex defines the index of the light for the effect
  14606. */
  14607. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14608. }
  14609. }
  14610. declare module BABYLON {
  14611. /** @hidden */
  14612. export var vrMultiviewToSingleviewPixelShader: {
  14613. name: string;
  14614. shader: string;
  14615. };
  14616. }
  14617. declare module BABYLON {
  14618. /**
  14619. * Renders to multiple views with a single draw call
  14620. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14621. */
  14622. export class MultiviewRenderTarget extends RenderTargetTexture {
  14623. /**
  14624. * Creates a multiview render target
  14625. * @param scene scene used with the render target
  14626. * @param size the size of the render target (used for each view)
  14627. */
  14628. constructor(scene: Scene, size?: number | {
  14629. width: number;
  14630. height: number;
  14631. } | {
  14632. ratio: number;
  14633. });
  14634. /**
  14635. * @hidden
  14636. * @param faceIndex the face index, if its a cube texture
  14637. */
  14638. _bindFrameBuffer(faceIndex?: number): void;
  14639. /**
  14640. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14641. * @returns the view count
  14642. */
  14643. getViewCount(): number;
  14644. }
  14645. }
  14646. declare module BABYLON {
  14647. /**
  14648. * Represents a camera frustum
  14649. */
  14650. export class Frustum {
  14651. /**
  14652. * Gets the planes representing the frustum
  14653. * @param transform matrix to be applied to the returned planes
  14654. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14655. */
  14656. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14657. /**
  14658. * Gets the near frustum plane transformed by the transform matrix
  14659. * @param transform transformation matrix to be applied to the resulting frustum plane
  14660. * @param frustumPlane the resuling frustum plane
  14661. */
  14662. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14663. /**
  14664. * Gets the far frustum plane transformed by the transform matrix
  14665. * @param transform transformation matrix to be applied to the resulting frustum plane
  14666. * @param frustumPlane the resuling frustum plane
  14667. */
  14668. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14669. /**
  14670. * Gets the left frustum plane transformed by the transform matrix
  14671. * @param transform transformation matrix to be applied to the resulting frustum plane
  14672. * @param frustumPlane the resuling frustum plane
  14673. */
  14674. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14675. /**
  14676. * Gets the right frustum plane transformed by the transform matrix
  14677. * @param transform transformation matrix to be applied to the resulting frustum plane
  14678. * @param frustumPlane the resuling frustum plane
  14679. */
  14680. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14681. /**
  14682. * Gets the top frustum plane transformed by the transform matrix
  14683. * @param transform transformation matrix to be applied to the resulting frustum plane
  14684. * @param frustumPlane the resuling frustum plane
  14685. */
  14686. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14687. /**
  14688. * Gets the bottom frustum plane transformed by the transform matrix
  14689. * @param transform transformation matrix to be applied to the resulting frustum plane
  14690. * @param frustumPlane the resuling frustum plane
  14691. */
  14692. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14693. /**
  14694. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14695. * @param transform transformation matrix to be applied to the resulting frustum planes
  14696. * @param frustumPlanes the resuling frustum planes
  14697. */
  14698. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14699. }
  14700. }
  14701. declare module BABYLON {
  14702. interface Engine {
  14703. /**
  14704. * Creates a new multiview render target
  14705. * @param width defines the width of the texture
  14706. * @param height defines the height of the texture
  14707. * @returns the created multiview texture
  14708. */
  14709. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14710. /**
  14711. * Binds a multiview framebuffer to be drawn to
  14712. * @param multiviewTexture texture to bind
  14713. */
  14714. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14715. }
  14716. interface Camera {
  14717. /**
  14718. * @hidden
  14719. * 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)
  14720. */
  14721. _useMultiviewToSingleView: boolean;
  14722. /**
  14723. * @hidden
  14724. * 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)
  14725. */
  14726. _multiviewTexture: Nullable<RenderTargetTexture>;
  14727. /**
  14728. * @hidden
  14729. * ensures the multiview texture of the camera exists and has the specified width/height
  14730. * @param width height to set on the multiview texture
  14731. * @param height width to set on the multiview texture
  14732. */
  14733. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14734. }
  14735. interface Scene {
  14736. /** @hidden */
  14737. _transformMatrixR: Matrix;
  14738. /** @hidden */
  14739. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14740. /** @hidden */
  14741. _createMultiviewUbo(): void;
  14742. /** @hidden */
  14743. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14744. /** @hidden */
  14745. _renderMultiviewToSingleView(camera: Camera): void;
  14746. }
  14747. }
  14748. declare module BABYLON {
  14749. /**
  14750. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14751. * This will not be used for webXR as it supports displaying texture arrays directly
  14752. */
  14753. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14754. /**
  14755. * Initializes a VRMultiviewToSingleview
  14756. * @param name name of the post process
  14757. * @param camera camera to be applied to
  14758. * @param scaleFactor scaling factor to the size of the output texture
  14759. */
  14760. constructor(name: string, camera: Camera, scaleFactor: number);
  14761. }
  14762. }
  14763. declare module BABYLON {
  14764. interface Engine {
  14765. /** @hidden */
  14766. _vrDisplay: any;
  14767. /** @hidden */
  14768. _vrSupported: boolean;
  14769. /** @hidden */
  14770. _oldSize: Size;
  14771. /** @hidden */
  14772. _oldHardwareScaleFactor: number;
  14773. /** @hidden */
  14774. _vrExclusivePointerMode: boolean;
  14775. /** @hidden */
  14776. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14777. /** @hidden */
  14778. _onVRDisplayPointerRestricted: () => void;
  14779. /** @hidden */
  14780. _onVRDisplayPointerUnrestricted: () => void;
  14781. /** @hidden */
  14782. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14783. /** @hidden */
  14784. _onVrDisplayDisconnect: Nullable<() => void>;
  14785. /** @hidden */
  14786. _onVrDisplayPresentChange: Nullable<() => void>;
  14787. /**
  14788. * Observable signaled when VR display mode changes
  14789. */
  14790. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14791. /**
  14792. * Observable signaled when VR request present is complete
  14793. */
  14794. onVRRequestPresentComplete: Observable<boolean>;
  14795. /**
  14796. * Observable signaled when VR request present starts
  14797. */
  14798. onVRRequestPresentStart: Observable<Engine>;
  14799. /**
  14800. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14801. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14802. */
  14803. isInVRExclusivePointerMode: boolean;
  14804. /**
  14805. * Gets a boolean indicating if a webVR device was detected
  14806. * @returns true if a webVR device was detected
  14807. */
  14808. isVRDevicePresent(): boolean;
  14809. /**
  14810. * Gets the current webVR device
  14811. * @returns the current webVR device (or null)
  14812. */
  14813. getVRDevice(): any;
  14814. /**
  14815. * Initializes a webVR display and starts listening to display change events
  14816. * The onVRDisplayChangedObservable will be notified upon these changes
  14817. * @returns A promise containing a VRDisplay and if vr is supported
  14818. */
  14819. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14820. /** @hidden */
  14821. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14822. /**
  14823. * Call this function to switch to webVR mode
  14824. * Will do nothing if webVR is not supported or if there is no webVR device
  14825. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14826. */
  14827. enableVR(): void;
  14828. /** @hidden */
  14829. _onVRFullScreenTriggered(): void;
  14830. }
  14831. }
  14832. declare module BABYLON {
  14833. /**
  14834. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14835. * IMPORTANT!! The data is right-hand data.
  14836. * @export
  14837. * @interface DevicePose
  14838. */
  14839. export interface DevicePose {
  14840. /**
  14841. * The position of the device, values in array are [x,y,z].
  14842. */
  14843. readonly position: Nullable<Float32Array>;
  14844. /**
  14845. * The linearVelocity of the device, values in array are [x,y,z].
  14846. */
  14847. readonly linearVelocity: Nullable<Float32Array>;
  14848. /**
  14849. * The linearAcceleration of the device, values in array are [x,y,z].
  14850. */
  14851. readonly linearAcceleration: Nullable<Float32Array>;
  14852. /**
  14853. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14854. */
  14855. readonly orientation: Nullable<Float32Array>;
  14856. /**
  14857. * The angularVelocity of the device, values in array are [x,y,z].
  14858. */
  14859. readonly angularVelocity: Nullable<Float32Array>;
  14860. /**
  14861. * The angularAcceleration of the device, values in array are [x,y,z].
  14862. */
  14863. readonly angularAcceleration: Nullable<Float32Array>;
  14864. }
  14865. /**
  14866. * Interface representing a pose controlled object in Babylon.
  14867. * A pose controlled object has both regular pose values as well as pose values
  14868. * from an external device such as a VR head mounted display
  14869. */
  14870. export interface PoseControlled {
  14871. /**
  14872. * The position of the object in babylon space.
  14873. */
  14874. position: Vector3;
  14875. /**
  14876. * The rotation quaternion of the object in babylon space.
  14877. */
  14878. rotationQuaternion: Quaternion;
  14879. /**
  14880. * The position of the device in babylon space.
  14881. */
  14882. devicePosition?: Vector3;
  14883. /**
  14884. * The rotation quaternion of the device in babylon space.
  14885. */
  14886. deviceRotationQuaternion: Quaternion;
  14887. /**
  14888. * The raw pose coming from the device.
  14889. */
  14890. rawPose: Nullable<DevicePose>;
  14891. /**
  14892. * The scale of the device to be used when translating from device space to babylon space.
  14893. */
  14894. deviceScaleFactor: number;
  14895. /**
  14896. * Updates the poseControlled values based on the input device pose.
  14897. * @param poseData the pose data to update the object with
  14898. */
  14899. updateFromDevice(poseData: DevicePose): void;
  14900. }
  14901. /**
  14902. * Set of options to customize the webVRCamera
  14903. */
  14904. export interface WebVROptions {
  14905. /**
  14906. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14907. */
  14908. trackPosition?: boolean;
  14909. /**
  14910. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14911. */
  14912. positionScale?: number;
  14913. /**
  14914. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14915. */
  14916. displayName?: string;
  14917. /**
  14918. * Should the native controller meshes be initialized. (default: true)
  14919. */
  14920. controllerMeshes?: boolean;
  14921. /**
  14922. * Creating a default HemiLight only on controllers. (default: true)
  14923. */
  14924. defaultLightingOnControllers?: boolean;
  14925. /**
  14926. * If you don't want to use the default VR button of the helper. (default: false)
  14927. */
  14928. useCustomVRButton?: boolean;
  14929. /**
  14930. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14931. */
  14932. customVRButton?: HTMLButtonElement;
  14933. /**
  14934. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14935. */
  14936. rayLength?: number;
  14937. /**
  14938. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14939. */
  14940. defaultHeight?: number;
  14941. /**
  14942. * If multiview should be used if availible (default: false)
  14943. */
  14944. useMultiview?: boolean;
  14945. }
  14946. /**
  14947. * This represents a WebVR camera.
  14948. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14949. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14950. */
  14951. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14952. private webVROptions;
  14953. /**
  14954. * @hidden
  14955. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14956. */
  14957. _vrDevice: any;
  14958. /**
  14959. * The rawPose of the vrDevice.
  14960. */
  14961. rawPose: Nullable<DevicePose>;
  14962. private _onVREnabled;
  14963. private _specsVersion;
  14964. private _attached;
  14965. private _frameData;
  14966. protected _descendants: Array<Node>;
  14967. private _deviceRoomPosition;
  14968. /** @hidden */
  14969. _deviceRoomRotationQuaternion: Quaternion;
  14970. private _standingMatrix;
  14971. /**
  14972. * Represents device position in babylon space.
  14973. */
  14974. devicePosition: Vector3;
  14975. /**
  14976. * Represents device rotation in babylon space.
  14977. */
  14978. deviceRotationQuaternion: Quaternion;
  14979. /**
  14980. * The scale of the device to be used when translating from device space to babylon space.
  14981. */
  14982. deviceScaleFactor: number;
  14983. private _deviceToWorld;
  14984. private _worldToDevice;
  14985. /**
  14986. * References to the webVR controllers for the vrDevice.
  14987. */
  14988. controllers: Array<WebVRController>;
  14989. /**
  14990. * Emits an event when a controller is attached.
  14991. */
  14992. onControllersAttachedObservable: Observable<WebVRController[]>;
  14993. /**
  14994. * Emits an event when a controller's mesh has been loaded;
  14995. */
  14996. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14997. /**
  14998. * Emits an event when the HMD's pose has been updated.
  14999. */
  15000. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15001. private _poseSet;
  15002. /**
  15003. * If the rig cameras be used as parent instead of this camera.
  15004. */
  15005. rigParenting: boolean;
  15006. private _lightOnControllers;
  15007. private _defaultHeight?;
  15008. /**
  15009. * Instantiates a WebVRFreeCamera.
  15010. * @param name The name of the WebVRFreeCamera
  15011. * @param position The starting anchor position for the camera
  15012. * @param scene The scene the camera belongs to
  15013. * @param webVROptions a set of customizable options for the webVRCamera
  15014. */
  15015. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15016. /**
  15017. * Gets the device distance from the ground in meters.
  15018. * @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.
  15019. */
  15020. deviceDistanceToRoomGround(): number;
  15021. /**
  15022. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15023. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15024. */
  15025. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15026. /**
  15027. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15028. * @returns A promise with a boolean set to if the standing matrix is supported.
  15029. */
  15030. useStandingMatrixAsync(): Promise<boolean>;
  15031. /**
  15032. * Disposes the camera
  15033. */
  15034. dispose(): void;
  15035. /**
  15036. * Gets a vrController by name.
  15037. * @param name The name of the controller to retreive
  15038. * @returns the controller matching the name specified or null if not found
  15039. */
  15040. getControllerByName(name: string): Nullable<WebVRController>;
  15041. private _leftController;
  15042. /**
  15043. * The controller corresponding to the users left hand.
  15044. */
  15045. readonly leftController: Nullable<WebVRController>;
  15046. private _rightController;
  15047. /**
  15048. * The controller corresponding to the users right hand.
  15049. */
  15050. readonly rightController: Nullable<WebVRController>;
  15051. /**
  15052. * Casts a ray forward from the vrCamera's gaze.
  15053. * @param length Length of the ray (default: 100)
  15054. * @returns the ray corresponding to the gaze
  15055. */
  15056. getForwardRay(length?: number): Ray;
  15057. /**
  15058. * @hidden
  15059. * Updates the camera based on device's frame data
  15060. */
  15061. _checkInputs(): void;
  15062. /**
  15063. * Updates the poseControlled values based on the input device pose.
  15064. * @param poseData Pose coming from the device
  15065. */
  15066. updateFromDevice(poseData: DevicePose): void;
  15067. private _htmlElementAttached;
  15068. private _detachIfAttached;
  15069. /**
  15070. * WebVR's attach control will start broadcasting frames to the device.
  15071. * Note that in certain browsers (chrome for example) this function must be called
  15072. * within a user-interaction callback. Example:
  15073. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15074. *
  15075. * @param element html element to attach the vrDevice to
  15076. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15077. */
  15078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15079. /**
  15080. * Detaches the camera from the html element and disables VR
  15081. *
  15082. * @param element html element to detach from
  15083. */
  15084. detachControl(element: HTMLElement): void;
  15085. /**
  15086. * @returns the name of this class
  15087. */
  15088. getClassName(): string;
  15089. /**
  15090. * Calls resetPose on the vrDisplay
  15091. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15092. */
  15093. resetToCurrentRotation(): void;
  15094. /**
  15095. * @hidden
  15096. * Updates the rig cameras (left and right eye)
  15097. */
  15098. _updateRigCameras(): void;
  15099. private _workingVector;
  15100. private _oneVector;
  15101. private _workingMatrix;
  15102. private updateCacheCalled;
  15103. private _correctPositionIfNotTrackPosition;
  15104. /**
  15105. * @hidden
  15106. * Updates the cached values of the camera
  15107. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15108. */
  15109. _updateCache(ignoreParentClass?: boolean): void;
  15110. /**
  15111. * @hidden
  15112. * Get current device position in babylon world
  15113. */
  15114. _computeDevicePosition(): void;
  15115. /**
  15116. * Updates the current device position and rotation in the babylon world
  15117. */
  15118. update(): void;
  15119. /**
  15120. * @hidden
  15121. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15122. * @returns an identity matrix
  15123. */
  15124. _getViewMatrix(): Matrix;
  15125. private _tmpMatrix;
  15126. /**
  15127. * This function is called by the two RIG cameras.
  15128. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15129. * @hidden
  15130. */
  15131. _getWebVRViewMatrix(): Matrix;
  15132. /** @hidden */
  15133. _getWebVRProjectionMatrix(): Matrix;
  15134. private _onGamepadConnectedObserver;
  15135. private _onGamepadDisconnectedObserver;
  15136. private _updateCacheWhenTrackingDisabledObserver;
  15137. /**
  15138. * Initializes the controllers and their meshes
  15139. */
  15140. initControllers(): void;
  15141. }
  15142. }
  15143. declare module BABYLON {
  15144. /**
  15145. * Size options for a post process
  15146. */
  15147. export type PostProcessOptions = {
  15148. width: number;
  15149. height: number;
  15150. };
  15151. /**
  15152. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15153. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15154. */
  15155. export class PostProcess {
  15156. /** Name of the PostProcess. */
  15157. name: string;
  15158. /**
  15159. * Gets or sets the unique id of the post process
  15160. */
  15161. uniqueId: number;
  15162. /**
  15163. * Width of the texture to apply the post process on
  15164. */
  15165. width: number;
  15166. /**
  15167. * Height of the texture to apply the post process on
  15168. */
  15169. height: number;
  15170. /**
  15171. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15172. * @hidden
  15173. */
  15174. _outputTexture: Nullable<InternalTexture>;
  15175. /**
  15176. * Sampling mode used by the shader
  15177. * See https://doc.babylonjs.com/classes/3.1/texture
  15178. */
  15179. renderTargetSamplingMode: number;
  15180. /**
  15181. * Clear color to use when screen clearing
  15182. */
  15183. clearColor: Color4;
  15184. /**
  15185. * If the buffer needs to be cleared before applying the post process. (default: true)
  15186. * Should be set to false if shader will overwrite all previous pixels.
  15187. */
  15188. autoClear: boolean;
  15189. /**
  15190. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15191. */
  15192. alphaMode: number;
  15193. /**
  15194. * Sets the setAlphaBlendConstants of the babylon engine
  15195. */
  15196. alphaConstants: Color4;
  15197. /**
  15198. * Animations to be used for the post processing
  15199. */
  15200. animations: Animation[];
  15201. /**
  15202. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15203. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15204. */
  15205. enablePixelPerfectMode: boolean;
  15206. /**
  15207. * Force the postprocess to be applied without taking in account viewport
  15208. */
  15209. forceFullscreenViewport: boolean;
  15210. /**
  15211. * List of inspectable custom properties (used by the Inspector)
  15212. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15213. */
  15214. inspectableCustomProperties: IInspectable[];
  15215. /**
  15216. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15217. *
  15218. * | Value | Type | Description |
  15219. * | ----- | ----------------------------------- | ----------- |
  15220. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15221. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15222. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15223. *
  15224. */
  15225. scaleMode: number;
  15226. /**
  15227. * Force textures to be a power of two (default: false)
  15228. */
  15229. alwaysForcePOT: boolean;
  15230. private _samples;
  15231. /**
  15232. * Number of sample textures (default: 1)
  15233. */
  15234. samples: number;
  15235. /**
  15236. * Modify the scale of the post process to be the same as the viewport (default: false)
  15237. */
  15238. adaptScaleToCurrentViewport: boolean;
  15239. private _camera;
  15240. private _scene;
  15241. private _engine;
  15242. private _options;
  15243. private _reusable;
  15244. private _textureType;
  15245. /**
  15246. * Smart array of input and output textures for the post process.
  15247. * @hidden
  15248. */
  15249. _textures: SmartArray<InternalTexture>;
  15250. /**
  15251. * The index in _textures that corresponds to the output texture.
  15252. * @hidden
  15253. */
  15254. _currentRenderTextureInd: number;
  15255. private _effect;
  15256. private _samplers;
  15257. private _fragmentUrl;
  15258. private _vertexUrl;
  15259. private _parameters;
  15260. private _scaleRatio;
  15261. protected _indexParameters: any;
  15262. private _shareOutputWithPostProcess;
  15263. private _texelSize;
  15264. private _forcedOutputTexture;
  15265. /**
  15266. * Returns the fragment url or shader name used in the post process.
  15267. * @returns the fragment url or name in the shader store.
  15268. */
  15269. getEffectName(): string;
  15270. /**
  15271. * An event triggered when the postprocess is activated.
  15272. */
  15273. onActivateObservable: Observable<Camera>;
  15274. private _onActivateObserver;
  15275. /**
  15276. * A function that is added to the onActivateObservable
  15277. */
  15278. onActivate: Nullable<(camera: Camera) => void>;
  15279. /**
  15280. * An event triggered when the postprocess changes its size.
  15281. */
  15282. onSizeChangedObservable: Observable<PostProcess>;
  15283. private _onSizeChangedObserver;
  15284. /**
  15285. * A function that is added to the onSizeChangedObservable
  15286. */
  15287. onSizeChanged: (postProcess: PostProcess) => void;
  15288. /**
  15289. * An event triggered when the postprocess applies its effect.
  15290. */
  15291. onApplyObservable: Observable<Effect>;
  15292. private _onApplyObserver;
  15293. /**
  15294. * A function that is added to the onApplyObservable
  15295. */
  15296. onApply: (effect: Effect) => void;
  15297. /**
  15298. * An event triggered before rendering the postprocess
  15299. */
  15300. onBeforeRenderObservable: Observable<Effect>;
  15301. private _onBeforeRenderObserver;
  15302. /**
  15303. * A function that is added to the onBeforeRenderObservable
  15304. */
  15305. onBeforeRender: (effect: Effect) => void;
  15306. /**
  15307. * An event triggered after rendering the postprocess
  15308. */
  15309. onAfterRenderObservable: Observable<Effect>;
  15310. private _onAfterRenderObserver;
  15311. /**
  15312. * A function that is added to the onAfterRenderObservable
  15313. */
  15314. onAfterRender: (efect: Effect) => void;
  15315. /**
  15316. * 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
  15317. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15318. */
  15319. inputTexture: InternalTexture;
  15320. /**
  15321. * Gets the camera which post process is applied to.
  15322. * @returns The camera the post process is applied to.
  15323. */
  15324. getCamera(): Camera;
  15325. /**
  15326. * Gets the texel size of the postprocess.
  15327. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15328. */
  15329. readonly texelSize: Vector2;
  15330. /**
  15331. * Creates a new instance PostProcess
  15332. * @param name The name of the PostProcess.
  15333. * @param fragmentUrl The url of the fragment shader to be used.
  15334. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15335. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15336. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15337. * @param camera The camera to apply the render pass to.
  15338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15339. * @param engine The engine which the post process will be applied. (default: current engine)
  15340. * @param reusable If the post process can be reused on the same frame. (default: false)
  15341. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15342. * @param textureType Type of textures used when performing the post process. (default: 0)
  15343. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15344. * @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
  15345. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15346. */
  15347. constructor(
  15348. /** Name of the PostProcess. */
  15349. 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);
  15350. /**
  15351. * Gets a string idenfifying the name of the class
  15352. * @returns "PostProcess" string
  15353. */
  15354. getClassName(): string;
  15355. /**
  15356. * Gets the engine which this post process belongs to.
  15357. * @returns The engine the post process was enabled with.
  15358. */
  15359. getEngine(): Engine;
  15360. /**
  15361. * The effect that is created when initializing the post process.
  15362. * @returns The created effect corresponding the the postprocess.
  15363. */
  15364. getEffect(): Effect;
  15365. /**
  15366. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15367. * @param postProcess The post process to share the output with.
  15368. * @returns This post process.
  15369. */
  15370. shareOutputWith(postProcess: PostProcess): PostProcess;
  15371. /**
  15372. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15373. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15374. */
  15375. useOwnOutput(): void;
  15376. /**
  15377. * Updates the effect with the current post process compile time values and recompiles the shader.
  15378. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15379. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15380. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15381. * @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
  15382. * @param onCompiled Called when the shader has been compiled.
  15383. * @param onError Called if there is an error when compiling a shader.
  15384. */
  15385. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15386. /**
  15387. * The post process is reusable if it can be used multiple times within one frame.
  15388. * @returns If the post process is reusable
  15389. */
  15390. isReusable(): boolean;
  15391. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15392. markTextureDirty(): void;
  15393. /**
  15394. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15395. * 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.
  15396. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15397. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15398. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15399. * @returns The target texture that was bound to be written to.
  15400. */
  15401. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15402. /**
  15403. * If the post process is supported.
  15404. */
  15405. readonly isSupported: boolean;
  15406. /**
  15407. * The aspect ratio of the output texture.
  15408. */
  15409. readonly aspectRatio: number;
  15410. /**
  15411. * Get a value indicating if the post-process is ready to be used
  15412. * @returns true if the post-process is ready (shader is compiled)
  15413. */
  15414. isReady(): boolean;
  15415. /**
  15416. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15417. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15418. */
  15419. apply(): Nullable<Effect>;
  15420. private _disposeTextures;
  15421. /**
  15422. * Disposes the post process.
  15423. * @param camera The camera to dispose the post process on.
  15424. */
  15425. dispose(camera?: Camera): void;
  15426. }
  15427. }
  15428. declare module BABYLON {
  15429. /** @hidden */
  15430. export var kernelBlurVaryingDeclaration: {
  15431. name: string;
  15432. shader: string;
  15433. };
  15434. }
  15435. declare module BABYLON {
  15436. /** @hidden */
  15437. export var kernelBlurFragment: {
  15438. name: string;
  15439. shader: string;
  15440. };
  15441. }
  15442. declare module BABYLON {
  15443. /** @hidden */
  15444. export var kernelBlurFragment2: {
  15445. name: string;
  15446. shader: string;
  15447. };
  15448. }
  15449. declare module BABYLON {
  15450. /** @hidden */
  15451. export var kernelBlurPixelShader: {
  15452. name: string;
  15453. shader: string;
  15454. };
  15455. }
  15456. declare module BABYLON {
  15457. /** @hidden */
  15458. export var kernelBlurVertex: {
  15459. name: string;
  15460. shader: string;
  15461. };
  15462. }
  15463. declare module BABYLON {
  15464. /** @hidden */
  15465. export var kernelBlurVertexShader: {
  15466. name: string;
  15467. shader: string;
  15468. };
  15469. }
  15470. declare module BABYLON {
  15471. /**
  15472. * The Blur Post Process which blurs an image based on a kernel and direction.
  15473. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15474. */
  15475. export class BlurPostProcess extends PostProcess {
  15476. /** The direction in which to blur the image. */
  15477. direction: Vector2;
  15478. private blockCompilation;
  15479. protected _kernel: number;
  15480. protected _idealKernel: number;
  15481. protected _packedFloat: boolean;
  15482. private _staticDefines;
  15483. /**
  15484. * Sets the length in pixels of the blur sample region
  15485. */
  15486. /**
  15487. * Gets the length in pixels of the blur sample region
  15488. */
  15489. kernel: number;
  15490. /**
  15491. * Sets wether or not the blur needs to unpack/repack floats
  15492. */
  15493. /**
  15494. * Gets wether or not the blur is unpacking/repacking floats
  15495. */
  15496. packedFloat: boolean;
  15497. /**
  15498. * Creates a new instance BlurPostProcess
  15499. * @param name The name of the effect.
  15500. * @param direction The direction in which to blur the image.
  15501. * @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.
  15502. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15503. * @param camera The camera to apply the render pass to.
  15504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15505. * @param engine The engine which the post process will be applied. (default: current engine)
  15506. * @param reusable If the post process can be reused on the same frame. (default: false)
  15507. * @param textureType Type of textures used when performing the post process. (default: 0)
  15508. * @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)
  15509. */
  15510. constructor(name: string,
  15511. /** The direction in which to blur the image. */
  15512. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15513. /**
  15514. * Updates the effect with the current post process compile time values and recompiles the shader.
  15515. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15516. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15517. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15518. * @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
  15519. * @param onCompiled Called when the shader has been compiled.
  15520. * @param onError Called if there is an error when compiling a shader.
  15521. */
  15522. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15523. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15524. /**
  15525. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15526. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15527. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15528. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15529. * The gaps between physical kernels are compensated for in the weighting of the samples
  15530. * @param idealKernel Ideal blur kernel.
  15531. * @return Nearest best kernel.
  15532. */
  15533. protected _nearestBestKernel(idealKernel: number): number;
  15534. /**
  15535. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15536. * @param x The point on the Gaussian distribution to sample.
  15537. * @return the value of the Gaussian function at x.
  15538. */
  15539. protected _gaussianWeight(x: number): number;
  15540. /**
  15541. * Generates a string that can be used as a floating point number in GLSL.
  15542. * @param x Value to print.
  15543. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15544. * @return GLSL float string.
  15545. */
  15546. protected _glslFloat(x: number, decimalFigures?: number): string;
  15547. }
  15548. }
  15549. declare module BABYLON {
  15550. /**
  15551. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15552. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15553. * You can then easily use it as a reflectionTexture on a flat surface.
  15554. * In case the surface is not a plane, please consider relying on reflection probes.
  15555. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15556. */
  15557. export class MirrorTexture extends RenderTargetTexture {
  15558. private scene;
  15559. /**
  15560. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15561. * 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.
  15562. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15563. */
  15564. mirrorPlane: Plane;
  15565. /**
  15566. * Define the blur ratio used to blur the reflection if needed.
  15567. */
  15568. blurRatio: number;
  15569. /**
  15570. * Define the adaptive blur kernel used to blur the reflection if needed.
  15571. * This will autocompute the closest best match for the `blurKernel`
  15572. */
  15573. adaptiveBlurKernel: number;
  15574. /**
  15575. * Define the blur kernel used to blur the reflection if needed.
  15576. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15577. */
  15578. blurKernel: number;
  15579. /**
  15580. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15581. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15582. */
  15583. blurKernelX: number;
  15584. /**
  15585. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15586. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15587. */
  15588. blurKernelY: number;
  15589. private _autoComputeBlurKernel;
  15590. protected _onRatioRescale(): void;
  15591. private _updateGammaSpace;
  15592. private _imageProcessingConfigChangeObserver;
  15593. private _transformMatrix;
  15594. private _mirrorMatrix;
  15595. private _savedViewMatrix;
  15596. private _blurX;
  15597. private _blurY;
  15598. private _adaptiveBlurKernel;
  15599. private _blurKernelX;
  15600. private _blurKernelY;
  15601. private _blurRatio;
  15602. /**
  15603. * Instantiates a Mirror Texture.
  15604. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15605. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15606. * You can then easily use it as a reflectionTexture on a flat surface.
  15607. * In case the surface is not a plane, please consider relying on reflection probes.
  15608. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15609. * @param name
  15610. * @param size
  15611. * @param scene
  15612. * @param generateMipMaps
  15613. * @param type
  15614. * @param samplingMode
  15615. * @param generateDepthBuffer
  15616. */
  15617. constructor(name: string, size: number | {
  15618. width: number;
  15619. height: number;
  15620. } | {
  15621. ratio: number;
  15622. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15623. private _preparePostProcesses;
  15624. /**
  15625. * Clone the mirror texture.
  15626. * @returns the cloned texture
  15627. */
  15628. clone(): MirrorTexture;
  15629. /**
  15630. * Serialize the texture to a JSON representation you could use in Parse later on
  15631. * @returns the serialized JSON representation
  15632. */
  15633. serialize(): any;
  15634. /**
  15635. * Dispose the texture and release its associated resources.
  15636. */
  15637. dispose(): void;
  15638. }
  15639. }
  15640. declare module BABYLON {
  15641. /**
  15642. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15643. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15644. */
  15645. export class Texture extends BaseTexture {
  15646. /**
  15647. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15648. */
  15649. static SerializeBuffers: boolean;
  15650. /** @hidden */
  15651. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15652. /** @hidden */
  15653. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15654. /** @hidden */
  15655. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15656. /** nearest is mag = nearest and min = nearest and mip = linear */
  15657. static readonly NEAREST_SAMPLINGMODE: number;
  15658. /** nearest is mag = nearest and min = nearest and mip = linear */
  15659. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15660. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15661. static readonly BILINEAR_SAMPLINGMODE: number;
  15662. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15663. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15664. /** Trilinear is mag = linear and min = linear and mip = linear */
  15665. static readonly TRILINEAR_SAMPLINGMODE: number;
  15666. /** Trilinear is mag = linear and min = linear and mip = linear */
  15667. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15668. /** mag = nearest and min = nearest and mip = nearest */
  15669. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15670. /** mag = nearest and min = linear and mip = nearest */
  15671. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15672. /** mag = nearest and min = linear and mip = linear */
  15673. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15674. /** mag = nearest and min = linear and mip = none */
  15675. static readonly NEAREST_LINEAR: number;
  15676. /** mag = nearest and min = nearest and mip = none */
  15677. static readonly NEAREST_NEAREST: number;
  15678. /** mag = linear and min = nearest and mip = nearest */
  15679. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15680. /** mag = linear and min = nearest and mip = linear */
  15681. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15682. /** mag = linear and min = linear and mip = none */
  15683. static readonly LINEAR_LINEAR: number;
  15684. /** mag = linear and min = nearest and mip = none */
  15685. static readonly LINEAR_NEAREST: number;
  15686. /** Explicit coordinates mode */
  15687. static readonly EXPLICIT_MODE: number;
  15688. /** Spherical coordinates mode */
  15689. static readonly SPHERICAL_MODE: number;
  15690. /** Planar coordinates mode */
  15691. static readonly PLANAR_MODE: number;
  15692. /** Cubic coordinates mode */
  15693. static readonly CUBIC_MODE: number;
  15694. /** Projection coordinates mode */
  15695. static readonly PROJECTION_MODE: number;
  15696. /** Inverse Cubic coordinates mode */
  15697. static readonly SKYBOX_MODE: number;
  15698. /** Inverse Cubic coordinates mode */
  15699. static readonly INVCUBIC_MODE: number;
  15700. /** Equirectangular coordinates mode */
  15701. static readonly EQUIRECTANGULAR_MODE: number;
  15702. /** Equirectangular Fixed coordinates mode */
  15703. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15704. /** Equirectangular Fixed Mirrored coordinates mode */
  15705. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15706. /** Texture is not repeating outside of 0..1 UVs */
  15707. static readonly CLAMP_ADDRESSMODE: number;
  15708. /** Texture is repeating outside of 0..1 UVs */
  15709. static readonly WRAP_ADDRESSMODE: number;
  15710. /** Texture is repeating and mirrored */
  15711. static readonly MIRROR_ADDRESSMODE: number;
  15712. /**
  15713. * 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
  15714. */
  15715. static UseSerializedUrlIfAny: boolean;
  15716. /**
  15717. * Define the url of the texture.
  15718. */
  15719. url: Nullable<string>;
  15720. /**
  15721. * Define an offset on the texture to offset the u coordinates of the UVs
  15722. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15723. */
  15724. uOffset: number;
  15725. /**
  15726. * Define an offset on the texture to offset the v coordinates of the UVs
  15727. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15728. */
  15729. vOffset: number;
  15730. /**
  15731. * Define an offset on the texture to scale the u coordinates of the UVs
  15732. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15733. */
  15734. uScale: number;
  15735. /**
  15736. * Define an offset on the texture to scale the v coordinates of the UVs
  15737. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15738. */
  15739. vScale: number;
  15740. /**
  15741. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15742. * @see http://doc.babylonjs.com/how_to/more_materials
  15743. */
  15744. uAng: number;
  15745. /**
  15746. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15747. * @see http://doc.babylonjs.com/how_to/more_materials
  15748. */
  15749. vAng: number;
  15750. /**
  15751. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15752. * @see http://doc.babylonjs.com/how_to/more_materials
  15753. */
  15754. wAng: number;
  15755. /**
  15756. * Defines the center of rotation (U)
  15757. */
  15758. uRotationCenter: number;
  15759. /**
  15760. * Defines the center of rotation (V)
  15761. */
  15762. vRotationCenter: number;
  15763. /**
  15764. * Defines the center of rotation (W)
  15765. */
  15766. wRotationCenter: number;
  15767. /**
  15768. * Are mip maps generated for this texture or not.
  15769. */
  15770. readonly noMipmap: boolean;
  15771. /**
  15772. * List of inspectable custom properties (used by the Inspector)
  15773. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15774. */
  15775. inspectableCustomProperties: Nullable<IInspectable[]>;
  15776. private _noMipmap;
  15777. /** @hidden */
  15778. _invertY: boolean;
  15779. private _rowGenerationMatrix;
  15780. private _cachedTextureMatrix;
  15781. private _projectionModeMatrix;
  15782. private _t0;
  15783. private _t1;
  15784. private _t2;
  15785. private _cachedUOffset;
  15786. private _cachedVOffset;
  15787. private _cachedUScale;
  15788. private _cachedVScale;
  15789. private _cachedUAng;
  15790. private _cachedVAng;
  15791. private _cachedWAng;
  15792. private _cachedProjectionMatrixId;
  15793. private _cachedCoordinatesMode;
  15794. /** @hidden */
  15795. protected _initialSamplingMode: number;
  15796. /** @hidden */
  15797. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15798. private _deleteBuffer;
  15799. protected _format: Nullable<number>;
  15800. private _delayedOnLoad;
  15801. private _delayedOnError;
  15802. /**
  15803. * Observable triggered once the texture has been loaded.
  15804. */
  15805. onLoadObservable: Observable<Texture>;
  15806. protected _isBlocking: boolean;
  15807. /**
  15808. * Is the texture preventing material to render while loading.
  15809. * If false, a default texture will be used instead of the loading one during the preparation step.
  15810. */
  15811. isBlocking: boolean;
  15812. /**
  15813. * Get the current sampling mode associated with the texture.
  15814. */
  15815. readonly samplingMode: number;
  15816. /**
  15817. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15818. */
  15819. readonly invertY: boolean;
  15820. /**
  15821. * Instantiates a new texture.
  15822. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15823. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15824. * @param url define the url of the picture to load as a texture
  15825. * @param scene define the scene or engine the texture will belong to
  15826. * @param noMipmap define if the texture will require mip maps or not
  15827. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15828. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15829. * @param onLoad define a callback triggered when the texture has been loaded
  15830. * @param onError define a callback triggered when an error occurred during the loading session
  15831. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15832. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15833. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15834. */
  15835. 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);
  15836. /**
  15837. * Update the url (and optional buffer) of this texture if url was null during construction.
  15838. * @param url the url of the texture
  15839. * @param buffer the buffer of the texture (defaults to null)
  15840. * @param onLoad callback called when the texture is loaded (defaults to null)
  15841. */
  15842. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15843. /**
  15844. * Finish the loading sequence of a texture flagged as delayed load.
  15845. * @hidden
  15846. */
  15847. delayLoad(): void;
  15848. private _prepareRowForTextureGeneration;
  15849. /**
  15850. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15851. * @returns the transform matrix of the texture.
  15852. */
  15853. getTextureMatrix(): Matrix;
  15854. /**
  15855. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15856. * @returns The reflection texture transform
  15857. */
  15858. getReflectionTextureMatrix(): Matrix;
  15859. /**
  15860. * Clones the texture.
  15861. * @returns the cloned texture
  15862. */
  15863. clone(): Texture;
  15864. /**
  15865. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15866. * @returns The JSON representation of the texture
  15867. */
  15868. serialize(): any;
  15869. /**
  15870. * Get the current class name of the texture useful for serialization or dynamic coding.
  15871. * @returns "Texture"
  15872. */
  15873. getClassName(): string;
  15874. /**
  15875. * Dispose the texture and release its associated resources.
  15876. */
  15877. dispose(): void;
  15878. /**
  15879. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15880. * @param parsedTexture Define the JSON representation of the texture
  15881. * @param scene Define the scene the parsed texture should be instantiated in
  15882. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15883. * @returns The parsed texture if successful
  15884. */
  15885. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15886. /**
  15887. * Creates a texture from its base 64 representation.
  15888. * @param data Define the base64 payload without the data: prefix
  15889. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15890. * @param scene Define the scene the texture should belong to
  15891. * @param noMipmap Forces the texture to not create mip map information if true
  15892. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15893. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15894. * @param onLoad define a callback triggered when the texture has been loaded
  15895. * @param onError define a callback triggered when an error occurred during the loading session
  15896. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15897. * @returns the created texture
  15898. */
  15899. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15900. /**
  15901. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15902. * @param data Define the base64 payload without the data: prefix
  15903. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15904. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15905. * @param scene Define the scene the texture should belong to
  15906. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15907. * @param noMipmap Forces the texture to not create mip map information if true
  15908. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15909. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15910. * @param onLoad define a callback triggered when the texture has been loaded
  15911. * @param onError define a callback triggered when an error occurred during the loading session
  15912. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15913. * @returns the created texture
  15914. */
  15915. 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;
  15916. }
  15917. }
  15918. declare module BABYLON {
  15919. /**
  15920. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15921. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15922. */
  15923. export class PostProcessManager {
  15924. private _scene;
  15925. private _indexBuffer;
  15926. private _vertexBuffers;
  15927. /**
  15928. * Creates a new instance PostProcess
  15929. * @param scene The scene that the post process is associated with.
  15930. */
  15931. constructor(scene: Scene);
  15932. private _prepareBuffers;
  15933. private _buildIndexBuffer;
  15934. /**
  15935. * Rebuilds the vertex buffers of the manager.
  15936. * @hidden
  15937. */
  15938. _rebuild(): void;
  15939. /**
  15940. * Prepares a frame to be run through a post process.
  15941. * @param sourceTexture The input texture to the post procesess. (default: null)
  15942. * @param postProcesses An array of post processes to be run. (default: null)
  15943. * @returns True if the post processes were able to be run.
  15944. * @hidden
  15945. */
  15946. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15947. /**
  15948. * Manually render a set of post processes to a texture.
  15949. * @param postProcesses An array of post processes to be run.
  15950. * @param targetTexture The target texture to render to.
  15951. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15952. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15953. * @param lodLevel defines which lod of the texture to render to
  15954. */
  15955. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15956. /**
  15957. * Finalize the result of the output of the postprocesses.
  15958. * @param doNotPresent If true the result will not be displayed to the screen.
  15959. * @param targetTexture The target texture to render to.
  15960. * @param faceIndex The index of the face to bind the target texture to.
  15961. * @param postProcesses The array of post processes to render.
  15962. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15963. * @hidden
  15964. */
  15965. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15966. /**
  15967. * Disposes of the post process manager.
  15968. */
  15969. dispose(): void;
  15970. }
  15971. }
  15972. declare module BABYLON {
  15973. /** Interface used by value gradients (color, factor, ...) */
  15974. export interface IValueGradient {
  15975. /**
  15976. * Gets or sets the gradient value (between 0 and 1)
  15977. */
  15978. gradient: number;
  15979. }
  15980. /** Class used to store color4 gradient */
  15981. export class ColorGradient implements IValueGradient {
  15982. /**
  15983. * Gets or sets the gradient value (between 0 and 1)
  15984. */
  15985. gradient: number;
  15986. /**
  15987. * Gets or sets first associated color
  15988. */
  15989. color1: Color4;
  15990. /**
  15991. * Gets or sets second associated color
  15992. */
  15993. color2?: Color4;
  15994. /**
  15995. * Will get a color picked randomly between color1 and color2.
  15996. * If color2 is undefined then color1 will be used
  15997. * @param result defines the target Color4 to store the result in
  15998. */
  15999. getColorToRef(result: Color4): void;
  16000. }
  16001. /** Class used to store color 3 gradient */
  16002. export class Color3Gradient implements IValueGradient {
  16003. /**
  16004. * Gets or sets the gradient value (between 0 and 1)
  16005. */
  16006. gradient: number;
  16007. /**
  16008. * Gets or sets the associated color
  16009. */
  16010. color: Color3;
  16011. }
  16012. /** Class used to store factor gradient */
  16013. export class FactorGradient implements IValueGradient {
  16014. /**
  16015. * Gets or sets the gradient value (between 0 and 1)
  16016. */
  16017. gradient: number;
  16018. /**
  16019. * Gets or sets first associated factor
  16020. */
  16021. factor1: number;
  16022. /**
  16023. * Gets or sets second associated factor
  16024. */
  16025. factor2?: number;
  16026. /**
  16027. * Will get a number picked randomly between factor1 and factor2.
  16028. * If factor2 is undefined then factor1 will be used
  16029. * @returns the picked number
  16030. */
  16031. getFactor(): number;
  16032. }
  16033. /**
  16034. * Helper used to simplify some generic gradient tasks
  16035. */
  16036. export class GradientHelper {
  16037. /**
  16038. * Gets the current gradient from an array of IValueGradient
  16039. * @param ratio defines the current ratio to get
  16040. * @param gradients defines the array of IValueGradient
  16041. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16042. */
  16043. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16044. }
  16045. }
  16046. declare module BABYLON {
  16047. interface ThinEngine {
  16048. /**
  16049. * Creates a dynamic texture
  16050. * @param width defines the width of the texture
  16051. * @param height defines the height of the texture
  16052. * @param generateMipMaps defines if the engine should generate the mip levels
  16053. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16054. * @returns the dynamic texture inside an InternalTexture
  16055. */
  16056. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16057. /**
  16058. * Update the content of a dynamic texture
  16059. * @param texture defines the texture to update
  16060. * @param canvas defines the canvas containing the source
  16061. * @param invertY defines if data must be stored with Y axis inverted
  16062. * @param premulAlpha defines if alpha is stored as premultiplied
  16063. * @param format defines the format of the data
  16064. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16065. */
  16066. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16067. }
  16068. }
  16069. declare module BABYLON {
  16070. /**
  16071. * A class extending Texture allowing drawing on a texture
  16072. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16073. */
  16074. export class DynamicTexture extends Texture {
  16075. private _generateMipMaps;
  16076. private _canvas;
  16077. private _context;
  16078. private _engine;
  16079. /**
  16080. * Creates a DynamicTexture
  16081. * @param name defines the name of the texture
  16082. * @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
  16083. * @param scene defines the scene where you want the texture
  16084. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16085. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16086. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16087. */
  16088. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16089. /**
  16090. * Get the current class name of the texture useful for serialization or dynamic coding.
  16091. * @returns "DynamicTexture"
  16092. */
  16093. getClassName(): string;
  16094. /**
  16095. * Gets the current state of canRescale
  16096. */
  16097. readonly canRescale: boolean;
  16098. private _recreate;
  16099. /**
  16100. * Scales the texture
  16101. * @param ratio the scale factor to apply to both width and height
  16102. */
  16103. scale(ratio: number): void;
  16104. /**
  16105. * Resizes the texture
  16106. * @param width the new width
  16107. * @param height the new height
  16108. */
  16109. scaleTo(width: number, height: number): void;
  16110. /**
  16111. * Gets the context of the canvas used by the texture
  16112. * @returns the canvas context of the dynamic texture
  16113. */
  16114. getContext(): CanvasRenderingContext2D;
  16115. /**
  16116. * Clears the texture
  16117. */
  16118. clear(): void;
  16119. /**
  16120. * Updates the texture
  16121. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16122. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16123. */
  16124. update(invertY?: boolean, premulAlpha?: boolean): void;
  16125. /**
  16126. * Draws text onto the texture
  16127. * @param text defines the text to be drawn
  16128. * @param x defines the placement of the text from the left
  16129. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16130. * @param font defines the font to be used with font-style, font-size, font-name
  16131. * @param color defines the color used for the text
  16132. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16133. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16134. * @param update defines whether texture is immediately update (default is true)
  16135. */
  16136. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16137. /**
  16138. * Clones the texture
  16139. * @returns the clone of the texture.
  16140. */
  16141. clone(): DynamicTexture;
  16142. /**
  16143. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16144. * @returns a serialized dynamic texture object
  16145. */
  16146. serialize(): any;
  16147. /** @hidden */
  16148. _rebuild(): void;
  16149. }
  16150. }
  16151. declare module BABYLON {
  16152. interface AbstractScene {
  16153. /**
  16154. * The list of procedural textures added to the scene
  16155. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16156. */
  16157. proceduralTextures: Array<ProceduralTexture>;
  16158. }
  16159. /**
  16160. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16161. * in a given scene.
  16162. */
  16163. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16164. /**
  16165. * The component name helpfull to identify the component in the list of scene components.
  16166. */
  16167. readonly name: string;
  16168. /**
  16169. * The scene the component belongs to.
  16170. */
  16171. scene: Scene;
  16172. /**
  16173. * Creates a new instance of the component for the given scene
  16174. * @param scene Defines the scene to register the component in
  16175. */
  16176. constructor(scene: Scene);
  16177. /**
  16178. * Registers the component in a given scene
  16179. */
  16180. register(): void;
  16181. /**
  16182. * Rebuilds the elements related to this component in case of
  16183. * context lost for instance.
  16184. */
  16185. rebuild(): void;
  16186. /**
  16187. * Disposes the component and the associated ressources.
  16188. */
  16189. dispose(): void;
  16190. private _beforeClear;
  16191. }
  16192. }
  16193. declare module BABYLON {
  16194. interface ThinEngine {
  16195. /**
  16196. * Creates a new render target cube texture
  16197. * @param size defines the size of the texture
  16198. * @param options defines the options used to create the texture
  16199. * @returns a new render target cube texture stored in an InternalTexture
  16200. */
  16201. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16202. }
  16203. }
  16204. declare module BABYLON {
  16205. /** @hidden */
  16206. export var proceduralVertexShader: {
  16207. name: string;
  16208. shader: string;
  16209. };
  16210. }
  16211. declare module BABYLON {
  16212. /**
  16213. * 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.
  16214. * This is the base class of any Procedural texture and contains most of the shareable code.
  16215. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16216. */
  16217. export class ProceduralTexture extends Texture {
  16218. isCube: boolean;
  16219. /**
  16220. * Define if the texture is enabled or not (disabled texture will not render)
  16221. */
  16222. isEnabled: boolean;
  16223. /**
  16224. * Define if the texture must be cleared before rendering (default is true)
  16225. */
  16226. autoClear: boolean;
  16227. /**
  16228. * Callback called when the texture is generated
  16229. */
  16230. onGenerated: () => void;
  16231. /**
  16232. * Event raised when the texture is generated
  16233. */
  16234. onGeneratedObservable: Observable<ProceduralTexture>;
  16235. /** @hidden */
  16236. _generateMipMaps: boolean;
  16237. /** @hidden **/
  16238. _effect: Effect;
  16239. /** @hidden */
  16240. _textures: {
  16241. [key: string]: Texture;
  16242. };
  16243. private _size;
  16244. private _currentRefreshId;
  16245. private _refreshRate;
  16246. private _vertexBuffers;
  16247. private _indexBuffer;
  16248. private _uniforms;
  16249. private _samplers;
  16250. private _fragment;
  16251. private _floats;
  16252. private _ints;
  16253. private _floatsArrays;
  16254. private _colors3;
  16255. private _colors4;
  16256. private _vectors2;
  16257. private _vectors3;
  16258. private _matrices;
  16259. private _fallbackTexture;
  16260. private _fallbackTextureUsed;
  16261. private _engine;
  16262. private _cachedDefines;
  16263. private _contentUpdateId;
  16264. private _contentData;
  16265. /**
  16266. * Instantiates a new procedural texture.
  16267. * 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.
  16268. * This is the base class of any Procedural texture and contains most of the shareable code.
  16269. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16270. * @param name Define the name of the texture
  16271. * @param size Define the size of the texture to create
  16272. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16273. * @param scene Define the scene the texture belongs to
  16274. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16275. * @param generateMipMaps Define if the texture should creates mip maps or not
  16276. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16277. */
  16278. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16279. /**
  16280. * The effect that is created when initializing the post process.
  16281. * @returns The created effect corresponding the the postprocess.
  16282. */
  16283. getEffect(): Effect;
  16284. /**
  16285. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16286. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16287. */
  16288. getContent(): Nullable<ArrayBufferView>;
  16289. private _createIndexBuffer;
  16290. /** @hidden */
  16291. _rebuild(): void;
  16292. /**
  16293. * Resets the texture in order to recreate its associated resources.
  16294. * This can be called in case of context loss
  16295. */
  16296. reset(): void;
  16297. protected _getDefines(): string;
  16298. /**
  16299. * Is the texture ready to be used ? (rendered at least once)
  16300. * @returns true if ready, otherwise, false.
  16301. */
  16302. isReady(): boolean;
  16303. /**
  16304. * Resets the refresh counter of the texture and start bak from scratch.
  16305. * Could be useful to regenerate the texture if it is setup to render only once.
  16306. */
  16307. resetRefreshCounter(): void;
  16308. /**
  16309. * Set the fragment shader to use in order to render the texture.
  16310. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16311. */
  16312. setFragment(fragment: any): void;
  16313. /**
  16314. * Define the refresh rate of the texture or the rendering frequency.
  16315. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16316. */
  16317. refreshRate: number;
  16318. /** @hidden */
  16319. _shouldRender(): boolean;
  16320. /**
  16321. * Get the size the texture is rendering at.
  16322. * @returns the size (texture is always squared)
  16323. */
  16324. getRenderSize(): number;
  16325. /**
  16326. * Resize the texture to new value.
  16327. * @param size Define the new size the texture should have
  16328. * @param generateMipMaps Define whether the new texture should create mip maps
  16329. */
  16330. resize(size: number, generateMipMaps: boolean): void;
  16331. private _checkUniform;
  16332. /**
  16333. * Set a texture in the shader program used to render.
  16334. * @param name Define the name of the uniform samplers as defined in the shader
  16335. * @param texture Define the texture to bind to this sampler
  16336. * @return the texture itself allowing "fluent" like uniform updates
  16337. */
  16338. setTexture(name: string, texture: Texture): ProceduralTexture;
  16339. /**
  16340. * Set a float in the shader.
  16341. * @param name Define the name of the uniform as defined in the shader
  16342. * @param value Define the value to give to the uniform
  16343. * @return the texture itself allowing "fluent" like uniform updates
  16344. */
  16345. setFloat(name: string, value: number): ProceduralTexture;
  16346. /**
  16347. * Set a int in the shader.
  16348. * @param name Define the name of the uniform as defined in the shader
  16349. * @param value Define the value to give to the uniform
  16350. * @return the texture itself allowing "fluent" like uniform updates
  16351. */
  16352. setInt(name: string, value: number): ProceduralTexture;
  16353. /**
  16354. * Set an array of floats in the shader.
  16355. * @param name Define the name of the uniform as defined in the shader
  16356. * @param value Define the value to give to the uniform
  16357. * @return the texture itself allowing "fluent" like uniform updates
  16358. */
  16359. setFloats(name: string, value: number[]): ProceduralTexture;
  16360. /**
  16361. * Set a vec3 in the shader from a Color3.
  16362. * @param name Define the name of the uniform as defined in the shader
  16363. * @param value Define the value to give to the uniform
  16364. * @return the texture itself allowing "fluent" like uniform updates
  16365. */
  16366. setColor3(name: string, value: Color3): ProceduralTexture;
  16367. /**
  16368. * Set a vec4 in the shader from a Color4.
  16369. * @param name Define the name of the uniform as defined in the shader
  16370. * @param value Define the value to give to the uniform
  16371. * @return the texture itself allowing "fluent" like uniform updates
  16372. */
  16373. setColor4(name: string, value: Color4): ProceduralTexture;
  16374. /**
  16375. * Set a vec2 in the shader from a Vector2.
  16376. * @param name Define the name of the uniform as defined in the shader
  16377. * @param value Define the value to give to the uniform
  16378. * @return the texture itself allowing "fluent" like uniform updates
  16379. */
  16380. setVector2(name: string, value: Vector2): ProceduralTexture;
  16381. /**
  16382. * Set a vec3 in the shader from a Vector3.
  16383. * @param name Define the name of the uniform as defined in the shader
  16384. * @param value Define the value to give to the uniform
  16385. * @return the texture itself allowing "fluent" like uniform updates
  16386. */
  16387. setVector3(name: string, value: Vector3): ProceduralTexture;
  16388. /**
  16389. * Set a mat4 in the shader from a MAtrix.
  16390. * @param name Define the name of the uniform as defined in the shader
  16391. * @param value Define the value to give to the uniform
  16392. * @return the texture itself allowing "fluent" like uniform updates
  16393. */
  16394. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16395. /**
  16396. * Render the texture to its associated render target.
  16397. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16398. */
  16399. render(useCameraPostProcess?: boolean): void;
  16400. /**
  16401. * Clone the texture.
  16402. * @returns the cloned texture
  16403. */
  16404. clone(): ProceduralTexture;
  16405. /**
  16406. * Dispose the texture and release its asoociated resources.
  16407. */
  16408. dispose(): void;
  16409. }
  16410. }
  16411. declare module BABYLON {
  16412. /**
  16413. * This represents the base class for particle system in Babylon.
  16414. * 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.
  16415. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16416. * @example https://doc.babylonjs.com/babylon101/particles
  16417. */
  16418. export class BaseParticleSystem {
  16419. /**
  16420. * Source color is added to the destination color without alpha affecting the result
  16421. */
  16422. static BLENDMODE_ONEONE: number;
  16423. /**
  16424. * Blend current color and particle color using particle’s alpha
  16425. */
  16426. static BLENDMODE_STANDARD: number;
  16427. /**
  16428. * Add current color and particle color multiplied by particle’s alpha
  16429. */
  16430. static BLENDMODE_ADD: number;
  16431. /**
  16432. * Multiply current color with particle color
  16433. */
  16434. static BLENDMODE_MULTIPLY: number;
  16435. /**
  16436. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16437. */
  16438. static BLENDMODE_MULTIPLYADD: number;
  16439. /**
  16440. * List of animations used by the particle system.
  16441. */
  16442. animations: Animation[];
  16443. /**
  16444. * The id of the Particle system.
  16445. */
  16446. id: string;
  16447. /**
  16448. * The friendly name of the Particle system.
  16449. */
  16450. name: string;
  16451. /**
  16452. * The rendering group used by the Particle system to chose when to render.
  16453. */
  16454. renderingGroupId: number;
  16455. /**
  16456. * The emitter represents the Mesh or position we are attaching the particle system to.
  16457. */
  16458. emitter: Nullable<AbstractMesh | Vector3>;
  16459. /**
  16460. * The maximum number of particles to emit per frame
  16461. */
  16462. emitRate: number;
  16463. /**
  16464. * If you want to launch only a few particles at once, that can be done, as well.
  16465. */
  16466. manualEmitCount: number;
  16467. /**
  16468. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16469. */
  16470. updateSpeed: number;
  16471. /**
  16472. * The amount of time the particle system is running (depends of the overall update speed).
  16473. */
  16474. targetStopDuration: number;
  16475. /**
  16476. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16477. */
  16478. disposeOnStop: boolean;
  16479. /**
  16480. * Minimum power of emitting particles.
  16481. */
  16482. minEmitPower: number;
  16483. /**
  16484. * Maximum power of emitting particles.
  16485. */
  16486. maxEmitPower: number;
  16487. /**
  16488. * Minimum life time of emitting particles.
  16489. */
  16490. minLifeTime: number;
  16491. /**
  16492. * Maximum life time of emitting particles.
  16493. */
  16494. maxLifeTime: number;
  16495. /**
  16496. * Minimum Size of emitting particles.
  16497. */
  16498. minSize: number;
  16499. /**
  16500. * Maximum Size of emitting particles.
  16501. */
  16502. maxSize: number;
  16503. /**
  16504. * Minimum scale of emitting particles on X axis.
  16505. */
  16506. minScaleX: number;
  16507. /**
  16508. * Maximum scale of emitting particles on X axis.
  16509. */
  16510. maxScaleX: number;
  16511. /**
  16512. * Minimum scale of emitting particles on Y axis.
  16513. */
  16514. minScaleY: number;
  16515. /**
  16516. * Maximum scale of emitting particles on Y axis.
  16517. */
  16518. maxScaleY: number;
  16519. /**
  16520. * Gets or sets the minimal initial rotation in radians.
  16521. */
  16522. minInitialRotation: number;
  16523. /**
  16524. * Gets or sets the maximal initial rotation in radians.
  16525. */
  16526. maxInitialRotation: number;
  16527. /**
  16528. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16529. */
  16530. minAngularSpeed: number;
  16531. /**
  16532. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16533. */
  16534. maxAngularSpeed: number;
  16535. /**
  16536. * The texture used to render each particle. (this can be a spritesheet)
  16537. */
  16538. particleTexture: Nullable<Texture>;
  16539. /**
  16540. * The layer mask we are rendering the particles through.
  16541. */
  16542. layerMask: number;
  16543. /**
  16544. * This can help using your own shader to render the particle system.
  16545. * The according effect will be created
  16546. */
  16547. customShader: any;
  16548. /**
  16549. * By default particle system starts as soon as they are created. This prevents the
  16550. * automatic start to happen and let you decide when to start emitting particles.
  16551. */
  16552. preventAutoStart: boolean;
  16553. private _noiseTexture;
  16554. /**
  16555. * Gets or sets a texture used to add random noise to particle positions
  16556. */
  16557. noiseTexture: Nullable<ProceduralTexture>;
  16558. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16559. noiseStrength: Vector3;
  16560. /**
  16561. * Callback triggered when the particle animation is ending.
  16562. */
  16563. onAnimationEnd: Nullable<() => void>;
  16564. /**
  16565. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16566. */
  16567. blendMode: number;
  16568. /**
  16569. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16570. * to override the particles.
  16571. */
  16572. forceDepthWrite: boolean;
  16573. /** 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 */
  16574. preWarmCycles: number;
  16575. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16576. preWarmStepOffset: number;
  16577. /**
  16578. * 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)
  16579. */
  16580. spriteCellChangeSpeed: number;
  16581. /**
  16582. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16583. */
  16584. startSpriteCellID: number;
  16585. /**
  16586. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16587. */
  16588. endSpriteCellID: number;
  16589. /**
  16590. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16591. */
  16592. spriteCellWidth: number;
  16593. /**
  16594. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16595. */
  16596. spriteCellHeight: number;
  16597. /**
  16598. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16599. */
  16600. spriteRandomStartCell: boolean;
  16601. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16602. translationPivot: Vector2;
  16603. /** @hidden */
  16604. protected _isAnimationSheetEnabled: boolean;
  16605. /**
  16606. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16607. */
  16608. beginAnimationOnStart: boolean;
  16609. /**
  16610. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16611. */
  16612. beginAnimationFrom: number;
  16613. /**
  16614. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16615. */
  16616. beginAnimationTo: number;
  16617. /**
  16618. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16619. */
  16620. beginAnimationLoop: boolean;
  16621. /**
  16622. * Gets or sets a world offset applied to all particles
  16623. */
  16624. worldOffset: Vector3;
  16625. /**
  16626. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16627. */
  16628. isAnimationSheetEnabled: boolean;
  16629. /**
  16630. * Get hosting scene
  16631. * @returns the scene
  16632. */
  16633. getScene(): Scene;
  16634. /**
  16635. * You can use gravity if you want to give an orientation to your particles.
  16636. */
  16637. gravity: Vector3;
  16638. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16639. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16640. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16641. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16642. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16643. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16644. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16645. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16646. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16647. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16648. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16649. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16650. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16651. /**
  16652. * Defines the delay in milliseconds before starting the system (0 by default)
  16653. */
  16654. startDelay: number;
  16655. /**
  16656. * Gets the current list of drag gradients.
  16657. * You must use addDragGradient and removeDragGradient to udpate this list
  16658. * @returns the list of drag gradients
  16659. */
  16660. getDragGradients(): Nullable<Array<FactorGradient>>;
  16661. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16662. limitVelocityDamping: number;
  16663. /**
  16664. * Gets the current list of limit velocity gradients.
  16665. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16666. * @returns the list of limit velocity gradients
  16667. */
  16668. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16669. /**
  16670. * Gets the current list of color gradients.
  16671. * You must use addColorGradient and removeColorGradient to udpate this list
  16672. * @returns the list of color gradients
  16673. */
  16674. getColorGradients(): Nullable<Array<ColorGradient>>;
  16675. /**
  16676. * Gets the current list of size gradients.
  16677. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16678. * @returns the list of size gradients
  16679. */
  16680. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16681. /**
  16682. * Gets the current list of color remap gradients.
  16683. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16684. * @returns the list of color remap gradients
  16685. */
  16686. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16687. /**
  16688. * Gets the current list of alpha remap gradients.
  16689. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16690. * @returns the list of alpha remap gradients
  16691. */
  16692. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16693. /**
  16694. * Gets the current list of life time gradients.
  16695. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16696. * @returns the list of life time gradients
  16697. */
  16698. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16699. /**
  16700. * Gets the current list of angular speed gradients.
  16701. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16702. * @returns the list of angular speed gradients
  16703. */
  16704. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16705. /**
  16706. * Gets the current list of velocity gradients.
  16707. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16708. * @returns the list of velocity gradients
  16709. */
  16710. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16711. /**
  16712. * Gets the current list of start size gradients.
  16713. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16714. * @returns the list of start size gradients
  16715. */
  16716. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16717. /**
  16718. * Gets the current list of emit rate gradients.
  16719. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16720. * @returns the list of emit rate gradients
  16721. */
  16722. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16723. /**
  16724. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16725. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16726. */
  16727. direction1: Vector3;
  16728. /**
  16729. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16730. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16731. */
  16732. direction2: Vector3;
  16733. /**
  16734. * 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.
  16735. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16736. */
  16737. minEmitBox: Vector3;
  16738. /**
  16739. * 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.
  16740. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16741. */
  16742. maxEmitBox: Vector3;
  16743. /**
  16744. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16745. */
  16746. color1: Color4;
  16747. /**
  16748. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16749. */
  16750. color2: Color4;
  16751. /**
  16752. * Color the particle will have at the end of its lifetime
  16753. */
  16754. colorDead: Color4;
  16755. /**
  16756. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16757. */
  16758. textureMask: Color4;
  16759. /**
  16760. * The particle emitter type defines the emitter used by the particle system.
  16761. * It can be for example box, sphere, or cone...
  16762. */
  16763. particleEmitterType: IParticleEmitterType;
  16764. /** @hidden */
  16765. _isSubEmitter: boolean;
  16766. /**
  16767. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16768. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16769. */
  16770. billboardMode: number;
  16771. protected _isBillboardBased: boolean;
  16772. /**
  16773. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16774. */
  16775. isBillboardBased: boolean;
  16776. /**
  16777. * The scene the particle system belongs to.
  16778. */
  16779. protected _scene: Scene;
  16780. /**
  16781. * Local cache of defines for image processing.
  16782. */
  16783. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16784. /**
  16785. * Default configuration related to image processing available in the standard Material.
  16786. */
  16787. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16788. /**
  16789. * Gets the image processing configuration used either in this material.
  16790. */
  16791. /**
  16792. * Sets the Default image processing configuration used either in the this material.
  16793. *
  16794. * If sets to null, the scene one is in use.
  16795. */
  16796. imageProcessingConfiguration: ImageProcessingConfiguration;
  16797. /**
  16798. * Attaches a new image processing configuration to the Standard Material.
  16799. * @param configuration
  16800. */
  16801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16802. /** @hidden */
  16803. protected _reset(): void;
  16804. /** @hidden */
  16805. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16806. /**
  16807. * Instantiates a particle system.
  16808. * 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.
  16809. * @param name The name of the particle system
  16810. */
  16811. constructor(name: string);
  16812. /**
  16813. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16814. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16815. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16816. * @returns the emitter
  16817. */
  16818. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16819. /**
  16820. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16821. * @param radius The radius of the hemisphere to emit from
  16822. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16823. * @returns the emitter
  16824. */
  16825. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16826. /**
  16827. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16828. * @param radius The radius of the sphere to emit from
  16829. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16830. * @returns the emitter
  16831. */
  16832. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16833. /**
  16834. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16835. * @param radius The radius of the sphere to emit from
  16836. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16837. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16838. * @returns the emitter
  16839. */
  16840. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16841. /**
  16842. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16843. * @param radius The radius of the emission cylinder
  16844. * @param height The height of the emission cylinder
  16845. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16846. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16847. * @returns the emitter
  16848. */
  16849. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16850. /**
  16851. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16852. * @param radius The radius of the cylinder to emit from
  16853. * @param height The height of the emission cylinder
  16854. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16855. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16856. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16857. * @returns the emitter
  16858. */
  16859. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16860. /**
  16861. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16862. * @param radius The radius of the cone to emit from
  16863. * @param angle The base angle of the cone
  16864. * @returns the emitter
  16865. */
  16866. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16867. /**
  16868. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16869. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16870. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16871. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16872. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16873. * @returns the emitter
  16874. */
  16875. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16876. }
  16877. }
  16878. declare module BABYLON {
  16879. /**
  16880. * Type of sub emitter
  16881. */
  16882. export enum SubEmitterType {
  16883. /**
  16884. * Attached to the particle over it's lifetime
  16885. */
  16886. ATTACHED = 0,
  16887. /**
  16888. * Created when the particle dies
  16889. */
  16890. END = 1
  16891. }
  16892. /**
  16893. * Sub emitter class used to emit particles from an existing particle
  16894. */
  16895. export class SubEmitter {
  16896. /**
  16897. * the particle system to be used by the sub emitter
  16898. */
  16899. particleSystem: ParticleSystem;
  16900. /**
  16901. * Type of the submitter (Default: END)
  16902. */
  16903. type: SubEmitterType;
  16904. /**
  16905. * 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)
  16906. * Note: This only is supported when using an emitter of type Mesh
  16907. */
  16908. inheritDirection: boolean;
  16909. /**
  16910. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16911. */
  16912. inheritedVelocityAmount: number;
  16913. /**
  16914. * Creates a sub emitter
  16915. * @param particleSystem the particle system to be used by the sub emitter
  16916. */
  16917. constructor(
  16918. /**
  16919. * the particle system to be used by the sub emitter
  16920. */
  16921. particleSystem: ParticleSystem);
  16922. /**
  16923. * Clones the sub emitter
  16924. * @returns the cloned sub emitter
  16925. */
  16926. clone(): SubEmitter;
  16927. /**
  16928. * Serialize current object to a JSON object
  16929. * @returns the serialized object
  16930. */
  16931. serialize(): any;
  16932. /** @hidden */
  16933. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16934. /**
  16935. * Creates a new SubEmitter from a serialized JSON version
  16936. * @param serializationObject defines the JSON object to read from
  16937. * @param scene defines the hosting scene
  16938. * @param rootUrl defines the rootUrl for data loading
  16939. * @returns a new SubEmitter
  16940. */
  16941. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16942. /** Release associated resources */
  16943. dispose(): void;
  16944. }
  16945. }
  16946. declare module BABYLON {
  16947. /** @hidden */
  16948. export var clipPlaneFragmentDeclaration: {
  16949. name: string;
  16950. shader: string;
  16951. };
  16952. }
  16953. declare module BABYLON {
  16954. /** @hidden */
  16955. export var imageProcessingDeclaration: {
  16956. name: string;
  16957. shader: string;
  16958. };
  16959. }
  16960. declare module BABYLON {
  16961. /** @hidden */
  16962. export var imageProcessingFunctions: {
  16963. name: string;
  16964. shader: string;
  16965. };
  16966. }
  16967. declare module BABYLON {
  16968. /** @hidden */
  16969. export var clipPlaneFragment: {
  16970. name: string;
  16971. shader: string;
  16972. };
  16973. }
  16974. declare module BABYLON {
  16975. /** @hidden */
  16976. export var particlesPixelShader: {
  16977. name: string;
  16978. shader: string;
  16979. };
  16980. }
  16981. declare module BABYLON {
  16982. /** @hidden */
  16983. export var clipPlaneVertexDeclaration: {
  16984. name: string;
  16985. shader: string;
  16986. };
  16987. }
  16988. declare module BABYLON {
  16989. /** @hidden */
  16990. export var clipPlaneVertex: {
  16991. name: string;
  16992. shader: string;
  16993. };
  16994. }
  16995. declare module BABYLON {
  16996. /** @hidden */
  16997. export var particlesVertexShader: {
  16998. name: string;
  16999. shader: string;
  17000. };
  17001. }
  17002. declare module BABYLON {
  17003. /**
  17004. * This represents a particle system in Babylon.
  17005. * 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.
  17006. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17007. * @example https://doc.babylonjs.com/babylon101/particles
  17008. */
  17009. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17010. /**
  17011. * Billboard mode will only apply to Y axis
  17012. */
  17013. static readonly BILLBOARDMODE_Y: number;
  17014. /**
  17015. * Billboard mode will apply to all axes
  17016. */
  17017. static readonly BILLBOARDMODE_ALL: number;
  17018. /**
  17019. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17020. */
  17021. static readonly BILLBOARDMODE_STRETCHED: number;
  17022. /**
  17023. * This function can be defined to provide custom update for active particles.
  17024. * This function will be called instead of regular update (age, position, color, etc.).
  17025. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17026. */
  17027. updateFunction: (particles: Particle[]) => void;
  17028. private _emitterWorldMatrix;
  17029. /**
  17030. * This function can be defined to specify initial direction for every new particle.
  17031. * It by default use the emitterType defined function
  17032. */
  17033. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17034. /**
  17035. * This function can be defined to specify initial position for every new particle.
  17036. * It by default use the emitterType defined function
  17037. */
  17038. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17039. /**
  17040. * @hidden
  17041. */
  17042. _inheritedVelocityOffset: Vector3;
  17043. /**
  17044. * An event triggered when the system is disposed
  17045. */
  17046. onDisposeObservable: Observable<ParticleSystem>;
  17047. private _onDisposeObserver;
  17048. /**
  17049. * Sets a callback that will be triggered when the system is disposed
  17050. */
  17051. onDispose: () => void;
  17052. private _particles;
  17053. private _epsilon;
  17054. private _capacity;
  17055. private _stockParticles;
  17056. private _newPartsExcess;
  17057. private _vertexData;
  17058. private _vertexBuffer;
  17059. private _vertexBuffers;
  17060. private _spriteBuffer;
  17061. private _indexBuffer;
  17062. private _effect;
  17063. private _customEffect;
  17064. private _cachedDefines;
  17065. private _scaledColorStep;
  17066. private _colorDiff;
  17067. private _scaledDirection;
  17068. private _scaledGravity;
  17069. private _currentRenderId;
  17070. private _alive;
  17071. private _useInstancing;
  17072. private _started;
  17073. private _stopped;
  17074. private _actualFrame;
  17075. private _scaledUpdateSpeed;
  17076. private _vertexBufferSize;
  17077. /** @hidden */
  17078. _currentEmitRateGradient: Nullable<FactorGradient>;
  17079. /** @hidden */
  17080. _currentEmitRate1: number;
  17081. /** @hidden */
  17082. _currentEmitRate2: number;
  17083. /** @hidden */
  17084. _currentStartSizeGradient: Nullable<FactorGradient>;
  17085. /** @hidden */
  17086. _currentStartSize1: number;
  17087. /** @hidden */
  17088. _currentStartSize2: number;
  17089. private readonly _rawTextureWidth;
  17090. private _rampGradientsTexture;
  17091. private _useRampGradients;
  17092. /** Gets or sets a boolean indicating that ramp gradients must be used
  17093. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17094. */
  17095. useRampGradients: boolean;
  17096. /**
  17097. * 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.
  17098. * 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: [])
  17099. */
  17100. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17101. private _subEmitters;
  17102. /**
  17103. * @hidden
  17104. * If the particle systems emitter should be disposed when the particle system is disposed
  17105. */
  17106. _disposeEmitterOnDispose: boolean;
  17107. /**
  17108. * The current active Sub-systems, this property is used by the root particle system only.
  17109. */
  17110. activeSubSystems: Array<ParticleSystem>;
  17111. private _rootParticleSystem;
  17112. /**
  17113. * Gets the current list of active particles
  17114. */
  17115. readonly particles: Particle[];
  17116. /**
  17117. * Returns the string "ParticleSystem"
  17118. * @returns a string containing the class name
  17119. */
  17120. getClassName(): string;
  17121. /**
  17122. * Instantiates a particle system.
  17123. * 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.
  17124. * @param name The name of the particle system
  17125. * @param capacity The max number of particles alive at the same time
  17126. * @param scene The scene the particle system belongs to
  17127. * @param customEffect a custom effect used to change the way particles are rendered by default
  17128. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17129. * @param epsilon Offset used to render the particles
  17130. */
  17131. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17132. private _addFactorGradient;
  17133. private _removeFactorGradient;
  17134. /**
  17135. * Adds a new life time gradient
  17136. * @param gradient defines the gradient to use (between 0 and 1)
  17137. * @param factor defines the life time factor to affect to the specified gradient
  17138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17139. * @returns the current particle system
  17140. */
  17141. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17142. /**
  17143. * Remove a specific life time gradient
  17144. * @param gradient defines the gradient to remove
  17145. * @returns the current particle system
  17146. */
  17147. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17148. /**
  17149. * Adds a new size gradient
  17150. * @param gradient defines the gradient to use (between 0 and 1)
  17151. * @param factor defines the size factor to affect to the specified gradient
  17152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17153. * @returns the current particle system
  17154. */
  17155. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17156. /**
  17157. * Remove a specific size gradient
  17158. * @param gradient defines the gradient to remove
  17159. * @returns the current particle system
  17160. */
  17161. removeSizeGradient(gradient: number): IParticleSystem;
  17162. /**
  17163. * Adds a new color remap gradient
  17164. * @param gradient defines the gradient to use (between 0 and 1)
  17165. * @param min defines the color remap minimal range
  17166. * @param max defines the color remap maximal range
  17167. * @returns the current particle system
  17168. */
  17169. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17170. /**
  17171. * Remove a specific color remap gradient
  17172. * @param gradient defines the gradient to remove
  17173. * @returns the current particle system
  17174. */
  17175. removeColorRemapGradient(gradient: number): IParticleSystem;
  17176. /**
  17177. * Adds a new alpha remap gradient
  17178. * @param gradient defines the gradient to use (between 0 and 1)
  17179. * @param min defines the alpha remap minimal range
  17180. * @param max defines the alpha remap maximal range
  17181. * @returns the current particle system
  17182. */
  17183. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17184. /**
  17185. * Remove a specific alpha remap gradient
  17186. * @param gradient defines the gradient to remove
  17187. * @returns the current particle system
  17188. */
  17189. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17190. /**
  17191. * Adds a new angular speed gradient
  17192. * @param gradient defines the gradient to use (between 0 and 1)
  17193. * @param factor defines the angular speed to affect to the specified gradient
  17194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17195. * @returns the current particle system
  17196. */
  17197. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17198. /**
  17199. * Remove a specific angular speed gradient
  17200. * @param gradient defines the gradient to remove
  17201. * @returns the current particle system
  17202. */
  17203. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17204. /**
  17205. * Adds a new velocity gradient
  17206. * @param gradient defines the gradient to use (between 0 and 1)
  17207. * @param factor defines the velocity to affect to the specified gradient
  17208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17209. * @returns the current particle system
  17210. */
  17211. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17212. /**
  17213. * Remove a specific velocity gradient
  17214. * @param gradient defines the gradient to remove
  17215. * @returns the current particle system
  17216. */
  17217. removeVelocityGradient(gradient: number): IParticleSystem;
  17218. /**
  17219. * Adds a new limit velocity gradient
  17220. * @param gradient defines the gradient to use (between 0 and 1)
  17221. * @param factor defines the limit velocity value to affect to the specified gradient
  17222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17223. * @returns the current particle system
  17224. */
  17225. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17226. /**
  17227. * Remove a specific limit velocity gradient
  17228. * @param gradient defines the gradient to remove
  17229. * @returns the current particle system
  17230. */
  17231. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17232. /**
  17233. * Adds a new drag gradient
  17234. * @param gradient defines the gradient to use (between 0 and 1)
  17235. * @param factor defines the drag value to affect to the specified gradient
  17236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17237. * @returns the current particle system
  17238. */
  17239. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17240. /**
  17241. * Remove a specific drag gradient
  17242. * @param gradient defines the gradient to remove
  17243. * @returns the current particle system
  17244. */
  17245. removeDragGradient(gradient: number): IParticleSystem;
  17246. /**
  17247. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17248. * @param gradient defines the gradient to use (between 0 and 1)
  17249. * @param factor defines the emit rate value to affect to the specified gradient
  17250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17251. * @returns the current particle system
  17252. */
  17253. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17254. /**
  17255. * Remove a specific emit rate gradient
  17256. * @param gradient defines the gradient to remove
  17257. * @returns the current particle system
  17258. */
  17259. removeEmitRateGradient(gradient: number): IParticleSystem;
  17260. /**
  17261. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17262. * @param gradient defines the gradient to use (between 0 and 1)
  17263. * @param factor defines the start size value to affect to the specified gradient
  17264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17265. * @returns the current particle system
  17266. */
  17267. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17268. /**
  17269. * Remove a specific start size gradient
  17270. * @param gradient defines the gradient to remove
  17271. * @returns the current particle system
  17272. */
  17273. removeStartSizeGradient(gradient: number): IParticleSystem;
  17274. private _createRampGradientTexture;
  17275. /**
  17276. * Gets the current list of ramp gradients.
  17277. * You must use addRampGradient and removeRampGradient to udpate this list
  17278. * @returns the list of ramp gradients
  17279. */
  17280. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17281. /**
  17282. * Adds a new ramp gradient used to remap particle colors
  17283. * @param gradient defines the gradient to use (between 0 and 1)
  17284. * @param color defines the color to affect to the specified gradient
  17285. * @returns the current particle system
  17286. */
  17287. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17288. /**
  17289. * Remove a specific ramp gradient
  17290. * @param gradient defines the gradient to remove
  17291. * @returns the current particle system
  17292. */
  17293. removeRampGradient(gradient: number): ParticleSystem;
  17294. /**
  17295. * Adds a new color gradient
  17296. * @param gradient defines the gradient to use (between 0 and 1)
  17297. * @param color1 defines the color to affect to the specified gradient
  17298. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17299. * @returns this particle system
  17300. */
  17301. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17302. /**
  17303. * Remove a specific color gradient
  17304. * @param gradient defines the gradient to remove
  17305. * @returns this particle system
  17306. */
  17307. removeColorGradient(gradient: number): IParticleSystem;
  17308. private _fetchR;
  17309. protected _reset(): void;
  17310. private _resetEffect;
  17311. private _createVertexBuffers;
  17312. private _createIndexBuffer;
  17313. /**
  17314. * Gets the maximum number of particles active at the same time.
  17315. * @returns The max number of active particles.
  17316. */
  17317. getCapacity(): number;
  17318. /**
  17319. * Gets whether there are still active particles in the system.
  17320. * @returns True if it is alive, otherwise false.
  17321. */
  17322. isAlive(): boolean;
  17323. /**
  17324. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17325. * @returns True if it has been started, otherwise false.
  17326. */
  17327. isStarted(): boolean;
  17328. private _prepareSubEmitterInternalArray;
  17329. /**
  17330. * Starts the particle system and begins to emit
  17331. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17332. */
  17333. start(delay?: number): void;
  17334. /**
  17335. * Stops the particle system.
  17336. * @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.
  17337. */
  17338. stop(stopSubEmitters?: boolean): void;
  17339. /**
  17340. * Remove all active particles
  17341. */
  17342. reset(): void;
  17343. /**
  17344. * @hidden (for internal use only)
  17345. */
  17346. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17347. /**
  17348. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17349. * Its lifetime will start back at 0.
  17350. */
  17351. recycleParticle: (particle: Particle) => void;
  17352. private _stopSubEmitters;
  17353. private _createParticle;
  17354. private _removeFromRoot;
  17355. private _emitFromParticle;
  17356. private _update;
  17357. /** @hidden */
  17358. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17359. /** @hidden */
  17360. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17361. /** @hidden */
  17362. private _getEffect;
  17363. /**
  17364. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17365. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17366. */
  17367. animate(preWarmOnly?: boolean): void;
  17368. private _appendParticleVertices;
  17369. /**
  17370. * Rebuilds the particle system.
  17371. */
  17372. rebuild(): void;
  17373. /**
  17374. * Is this system ready to be used/rendered
  17375. * @return true if the system is ready
  17376. */
  17377. isReady(): boolean;
  17378. private _render;
  17379. /**
  17380. * Renders the particle system in its current state.
  17381. * @returns the current number of particles
  17382. */
  17383. render(): number;
  17384. /**
  17385. * Disposes the particle system and free the associated resources
  17386. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17387. */
  17388. dispose(disposeTexture?: boolean): void;
  17389. /**
  17390. * Clones the particle system.
  17391. * @param name The name of the cloned object
  17392. * @param newEmitter The new emitter to use
  17393. * @returns the cloned particle system
  17394. */
  17395. clone(name: string, newEmitter: any): ParticleSystem;
  17396. /**
  17397. * Serializes the particle system to a JSON object.
  17398. * @returns the JSON object
  17399. */
  17400. serialize(): any;
  17401. /** @hidden */
  17402. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17403. /** @hidden */
  17404. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17405. /**
  17406. * Parses a JSON object to create a particle system.
  17407. * @param parsedParticleSystem The JSON object to parse
  17408. * @param scene The scene to create the particle system in
  17409. * @param rootUrl The root url to use to load external dependencies like texture
  17410. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17411. * @returns the Parsed particle system
  17412. */
  17413. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17414. }
  17415. }
  17416. declare module BABYLON {
  17417. /**
  17418. * A particle represents one of the element emitted by a particle system.
  17419. * This is mainly define by its coordinates, direction, velocity and age.
  17420. */
  17421. export class Particle {
  17422. /**
  17423. * The particle system the particle belongs to.
  17424. */
  17425. particleSystem: ParticleSystem;
  17426. private static _Count;
  17427. /**
  17428. * Unique ID of the particle
  17429. */
  17430. id: number;
  17431. /**
  17432. * The world position of the particle in the scene.
  17433. */
  17434. position: Vector3;
  17435. /**
  17436. * The world direction of the particle in the scene.
  17437. */
  17438. direction: Vector3;
  17439. /**
  17440. * The color of the particle.
  17441. */
  17442. color: Color4;
  17443. /**
  17444. * The color change of the particle per step.
  17445. */
  17446. colorStep: Color4;
  17447. /**
  17448. * Defines how long will the life of the particle be.
  17449. */
  17450. lifeTime: number;
  17451. /**
  17452. * The current age of the particle.
  17453. */
  17454. age: number;
  17455. /**
  17456. * The current size of the particle.
  17457. */
  17458. size: number;
  17459. /**
  17460. * The current scale of the particle.
  17461. */
  17462. scale: Vector2;
  17463. /**
  17464. * The current angle of the particle.
  17465. */
  17466. angle: number;
  17467. /**
  17468. * Defines how fast is the angle changing.
  17469. */
  17470. angularSpeed: number;
  17471. /**
  17472. * Defines the cell index used by the particle to be rendered from a sprite.
  17473. */
  17474. cellIndex: number;
  17475. /**
  17476. * The information required to support color remapping
  17477. */
  17478. remapData: Vector4;
  17479. /** @hidden */
  17480. _randomCellOffset?: number;
  17481. /** @hidden */
  17482. _initialDirection: Nullable<Vector3>;
  17483. /** @hidden */
  17484. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17485. /** @hidden */
  17486. _initialStartSpriteCellID: number;
  17487. /** @hidden */
  17488. _initialEndSpriteCellID: number;
  17489. /** @hidden */
  17490. _currentColorGradient: Nullable<ColorGradient>;
  17491. /** @hidden */
  17492. _currentColor1: Color4;
  17493. /** @hidden */
  17494. _currentColor2: Color4;
  17495. /** @hidden */
  17496. _currentSizeGradient: Nullable<FactorGradient>;
  17497. /** @hidden */
  17498. _currentSize1: number;
  17499. /** @hidden */
  17500. _currentSize2: number;
  17501. /** @hidden */
  17502. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17503. /** @hidden */
  17504. _currentAngularSpeed1: number;
  17505. /** @hidden */
  17506. _currentAngularSpeed2: number;
  17507. /** @hidden */
  17508. _currentVelocityGradient: Nullable<FactorGradient>;
  17509. /** @hidden */
  17510. _currentVelocity1: number;
  17511. /** @hidden */
  17512. _currentVelocity2: number;
  17513. /** @hidden */
  17514. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17515. /** @hidden */
  17516. _currentLimitVelocity1: number;
  17517. /** @hidden */
  17518. _currentLimitVelocity2: number;
  17519. /** @hidden */
  17520. _currentDragGradient: Nullable<FactorGradient>;
  17521. /** @hidden */
  17522. _currentDrag1: number;
  17523. /** @hidden */
  17524. _currentDrag2: number;
  17525. /** @hidden */
  17526. _randomNoiseCoordinates1: Vector3;
  17527. /** @hidden */
  17528. _randomNoiseCoordinates2: Vector3;
  17529. /**
  17530. * Creates a new instance Particle
  17531. * @param particleSystem the particle system the particle belongs to
  17532. */
  17533. constructor(
  17534. /**
  17535. * The particle system the particle belongs to.
  17536. */
  17537. particleSystem: ParticleSystem);
  17538. private updateCellInfoFromSystem;
  17539. /**
  17540. * Defines how the sprite cell index is updated for the particle
  17541. */
  17542. updateCellIndex(): void;
  17543. /** @hidden */
  17544. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17545. /** @hidden */
  17546. _inheritParticleInfoToSubEmitters(): void;
  17547. /** @hidden */
  17548. _reset(): void;
  17549. /**
  17550. * Copy the properties of particle to another one.
  17551. * @param other the particle to copy the information to.
  17552. */
  17553. copyTo(other: Particle): void;
  17554. }
  17555. }
  17556. declare module BABYLON {
  17557. /**
  17558. * Particle emitter represents a volume emitting particles.
  17559. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17560. */
  17561. export interface IParticleEmitterType {
  17562. /**
  17563. * Called by the particle System when the direction is computed for the created particle.
  17564. * @param worldMatrix is the world matrix of the particle system
  17565. * @param directionToUpdate is the direction vector to update with the result
  17566. * @param particle is the particle we are computed the direction for
  17567. */
  17568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17569. /**
  17570. * Called by the particle System when the position is computed for the created particle.
  17571. * @param worldMatrix is the world matrix of the particle system
  17572. * @param positionToUpdate is the position vector to update with the result
  17573. * @param particle is the particle we are computed the position for
  17574. */
  17575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17576. /**
  17577. * Clones the current emitter and returns a copy of it
  17578. * @returns the new emitter
  17579. */
  17580. clone(): IParticleEmitterType;
  17581. /**
  17582. * Called by the GPUParticleSystem to setup the update shader
  17583. * @param effect defines the update shader
  17584. */
  17585. applyToShader(effect: Effect): void;
  17586. /**
  17587. * Returns a string to use to update the GPU particles update shader
  17588. * @returns the effect defines string
  17589. */
  17590. getEffectDefines(): string;
  17591. /**
  17592. * Returns a string representing the class name
  17593. * @returns a string containing the class name
  17594. */
  17595. getClassName(): string;
  17596. /**
  17597. * Serializes the particle system to a JSON object.
  17598. * @returns the JSON object
  17599. */
  17600. serialize(): any;
  17601. /**
  17602. * Parse properties from a JSON object
  17603. * @param serializationObject defines the JSON object
  17604. */
  17605. parse(serializationObject: any): void;
  17606. }
  17607. }
  17608. declare module BABYLON {
  17609. /**
  17610. * Particle emitter emitting particles from the inside of a box.
  17611. * It emits the particles randomly between 2 given directions.
  17612. */
  17613. export class BoxParticleEmitter implements IParticleEmitterType {
  17614. /**
  17615. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17616. */
  17617. direction1: Vector3;
  17618. /**
  17619. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17620. */
  17621. direction2: Vector3;
  17622. /**
  17623. * 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.
  17624. */
  17625. minEmitBox: Vector3;
  17626. /**
  17627. * 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.
  17628. */
  17629. maxEmitBox: Vector3;
  17630. /**
  17631. * Creates a new instance BoxParticleEmitter
  17632. */
  17633. constructor();
  17634. /**
  17635. * Called by the particle System when the direction is computed for the created particle.
  17636. * @param worldMatrix is the world matrix of the particle system
  17637. * @param directionToUpdate is the direction vector to update with the result
  17638. * @param particle is the particle we are computed the direction for
  17639. */
  17640. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17641. /**
  17642. * Called by the particle System when the position is computed for the created particle.
  17643. * @param worldMatrix is the world matrix of the particle system
  17644. * @param positionToUpdate is the position vector to update with the result
  17645. * @param particle is the particle we are computed the position for
  17646. */
  17647. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17648. /**
  17649. * Clones the current emitter and returns a copy of it
  17650. * @returns the new emitter
  17651. */
  17652. clone(): BoxParticleEmitter;
  17653. /**
  17654. * Called by the GPUParticleSystem to setup the update shader
  17655. * @param effect defines the update shader
  17656. */
  17657. applyToShader(effect: Effect): void;
  17658. /**
  17659. * Returns a string to use to update the GPU particles update shader
  17660. * @returns a string containng the defines string
  17661. */
  17662. getEffectDefines(): string;
  17663. /**
  17664. * Returns the string "BoxParticleEmitter"
  17665. * @returns a string containing the class name
  17666. */
  17667. getClassName(): string;
  17668. /**
  17669. * Serializes the particle system to a JSON object.
  17670. * @returns the JSON object
  17671. */
  17672. serialize(): any;
  17673. /**
  17674. * Parse properties from a JSON object
  17675. * @param serializationObject defines the JSON object
  17676. */
  17677. parse(serializationObject: any): void;
  17678. }
  17679. }
  17680. declare module BABYLON {
  17681. /**
  17682. * Particle emitter emitting particles from the inside of a cone.
  17683. * It emits the particles alongside the cone volume from the base to the particle.
  17684. * The emission direction might be randomized.
  17685. */
  17686. export class ConeParticleEmitter implements IParticleEmitterType {
  17687. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17688. directionRandomizer: number;
  17689. private _radius;
  17690. private _angle;
  17691. private _height;
  17692. /**
  17693. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17694. */
  17695. radiusRange: number;
  17696. /**
  17697. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17698. */
  17699. heightRange: number;
  17700. /**
  17701. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17702. */
  17703. emitFromSpawnPointOnly: boolean;
  17704. /**
  17705. * Gets or sets the radius of the emission cone
  17706. */
  17707. radius: number;
  17708. /**
  17709. * Gets or sets the angle of the emission cone
  17710. */
  17711. angle: number;
  17712. private _buildHeight;
  17713. /**
  17714. * Creates a new instance ConeParticleEmitter
  17715. * @param radius the radius of the emission cone (1 by default)
  17716. * @param angle the cone base angle (PI by default)
  17717. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17718. */
  17719. constructor(radius?: number, angle?: number,
  17720. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17721. directionRandomizer?: number);
  17722. /**
  17723. * Called by the particle System when the direction is computed for the created particle.
  17724. * @param worldMatrix is the world matrix of the particle system
  17725. * @param directionToUpdate is the direction vector to update with the result
  17726. * @param particle is the particle we are computed the direction for
  17727. */
  17728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17729. /**
  17730. * Called by the particle System when the position is computed for the created particle.
  17731. * @param worldMatrix is the world matrix of the particle system
  17732. * @param positionToUpdate is the position vector to update with the result
  17733. * @param particle is the particle we are computed the position for
  17734. */
  17735. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17736. /**
  17737. * Clones the current emitter and returns a copy of it
  17738. * @returns the new emitter
  17739. */
  17740. clone(): ConeParticleEmitter;
  17741. /**
  17742. * Called by the GPUParticleSystem to setup the update shader
  17743. * @param effect defines the update shader
  17744. */
  17745. applyToShader(effect: Effect): void;
  17746. /**
  17747. * Returns a string to use to update the GPU particles update shader
  17748. * @returns a string containng the defines string
  17749. */
  17750. getEffectDefines(): string;
  17751. /**
  17752. * Returns the string "ConeParticleEmitter"
  17753. * @returns a string containing the class name
  17754. */
  17755. getClassName(): string;
  17756. /**
  17757. * Serializes the particle system to a JSON object.
  17758. * @returns the JSON object
  17759. */
  17760. serialize(): any;
  17761. /**
  17762. * Parse properties from a JSON object
  17763. * @param serializationObject defines the JSON object
  17764. */
  17765. parse(serializationObject: any): void;
  17766. }
  17767. }
  17768. declare module BABYLON {
  17769. /**
  17770. * Particle emitter emitting particles from the inside of a cylinder.
  17771. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17772. */
  17773. export class CylinderParticleEmitter implements IParticleEmitterType {
  17774. /**
  17775. * The radius of the emission cylinder.
  17776. */
  17777. radius: number;
  17778. /**
  17779. * The height of the emission cylinder.
  17780. */
  17781. height: number;
  17782. /**
  17783. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17784. */
  17785. radiusRange: number;
  17786. /**
  17787. * How much to randomize the particle direction [0-1].
  17788. */
  17789. directionRandomizer: number;
  17790. /**
  17791. * Creates a new instance CylinderParticleEmitter
  17792. * @param radius the radius of the emission cylinder (1 by default)
  17793. * @param height the height of the emission cylinder (1 by default)
  17794. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17795. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17796. */
  17797. constructor(
  17798. /**
  17799. * The radius of the emission cylinder.
  17800. */
  17801. radius?: number,
  17802. /**
  17803. * The height of the emission cylinder.
  17804. */
  17805. height?: number,
  17806. /**
  17807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17808. */
  17809. radiusRange?: number,
  17810. /**
  17811. * How much to randomize the particle direction [0-1].
  17812. */
  17813. directionRandomizer?: number);
  17814. /**
  17815. * Called by the particle System when the direction is computed for the created particle.
  17816. * @param worldMatrix is the world matrix of the particle system
  17817. * @param directionToUpdate is the direction vector to update with the result
  17818. * @param particle is the particle we are computed the direction for
  17819. */
  17820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17821. /**
  17822. * Called by the particle System when the position is computed for the created particle.
  17823. * @param worldMatrix is the world matrix of the particle system
  17824. * @param positionToUpdate is the position vector to update with the result
  17825. * @param particle is the particle we are computed the position for
  17826. */
  17827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17828. /**
  17829. * Clones the current emitter and returns a copy of it
  17830. * @returns the new emitter
  17831. */
  17832. clone(): CylinderParticleEmitter;
  17833. /**
  17834. * Called by the GPUParticleSystem to setup the update shader
  17835. * @param effect defines the update shader
  17836. */
  17837. applyToShader(effect: Effect): void;
  17838. /**
  17839. * Returns a string to use to update the GPU particles update shader
  17840. * @returns a string containng the defines string
  17841. */
  17842. getEffectDefines(): string;
  17843. /**
  17844. * Returns the string "CylinderParticleEmitter"
  17845. * @returns a string containing the class name
  17846. */
  17847. getClassName(): string;
  17848. /**
  17849. * Serializes the particle system to a JSON object.
  17850. * @returns the JSON object
  17851. */
  17852. serialize(): any;
  17853. /**
  17854. * Parse properties from a JSON object
  17855. * @param serializationObject defines the JSON object
  17856. */
  17857. parse(serializationObject: any): void;
  17858. }
  17859. /**
  17860. * Particle emitter emitting particles from the inside of a cylinder.
  17861. * It emits the particles randomly between two vectors.
  17862. */
  17863. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17864. /**
  17865. * The min limit of the emission direction.
  17866. */
  17867. direction1: Vector3;
  17868. /**
  17869. * The max limit of the emission direction.
  17870. */
  17871. direction2: Vector3;
  17872. /**
  17873. * Creates a new instance CylinderDirectedParticleEmitter
  17874. * @param radius the radius of the emission cylinder (1 by default)
  17875. * @param height the height of the emission cylinder (1 by default)
  17876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17877. * @param direction1 the min limit of the emission direction (up vector by default)
  17878. * @param direction2 the max limit of the emission direction (up vector by default)
  17879. */
  17880. constructor(radius?: number, height?: number, radiusRange?: number,
  17881. /**
  17882. * The min limit of the emission direction.
  17883. */
  17884. direction1?: Vector3,
  17885. /**
  17886. * The max limit of the emission direction.
  17887. */
  17888. direction2?: Vector3);
  17889. /**
  17890. * Called by the particle System when the direction is computed for the created particle.
  17891. * @param worldMatrix is the world matrix of the particle system
  17892. * @param directionToUpdate is the direction vector to update with the result
  17893. * @param particle is the particle we are computed the direction for
  17894. */
  17895. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17896. /**
  17897. * Clones the current emitter and returns a copy of it
  17898. * @returns the new emitter
  17899. */
  17900. clone(): CylinderDirectedParticleEmitter;
  17901. /**
  17902. * Called by the GPUParticleSystem to setup the update shader
  17903. * @param effect defines the update shader
  17904. */
  17905. applyToShader(effect: Effect): void;
  17906. /**
  17907. * Returns a string to use to update the GPU particles update shader
  17908. * @returns a string containng the defines string
  17909. */
  17910. getEffectDefines(): string;
  17911. /**
  17912. * Returns the string "CylinderDirectedParticleEmitter"
  17913. * @returns a string containing the class name
  17914. */
  17915. getClassName(): string;
  17916. /**
  17917. * Serializes the particle system to a JSON object.
  17918. * @returns the JSON object
  17919. */
  17920. serialize(): any;
  17921. /**
  17922. * Parse properties from a JSON object
  17923. * @param serializationObject defines the JSON object
  17924. */
  17925. parse(serializationObject: any): void;
  17926. }
  17927. }
  17928. declare module BABYLON {
  17929. /**
  17930. * Particle emitter emitting particles from the inside of a hemisphere.
  17931. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17932. */
  17933. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17934. /**
  17935. * The radius of the emission hemisphere.
  17936. */
  17937. radius: number;
  17938. /**
  17939. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17940. */
  17941. radiusRange: number;
  17942. /**
  17943. * How much to randomize the particle direction [0-1].
  17944. */
  17945. directionRandomizer: number;
  17946. /**
  17947. * Creates a new instance HemisphericParticleEmitter
  17948. * @param radius the radius of the emission hemisphere (1 by default)
  17949. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17950. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17951. */
  17952. constructor(
  17953. /**
  17954. * The radius of the emission hemisphere.
  17955. */
  17956. radius?: number,
  17957. /**
  17958. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17959. */
  17960. radiusRange?: number,
  17961. /**
  17962. * How much to randomize the particle direction [0-1].
  17963. */
  17964. directionRandomizer?: number);
  17965. /**
  17966. * Called by the particle System when the direction is computed for the created particle.
  17967. * @param worldMatrix is the world matrix of the particle system
  17968. * @param directionToUpdate is the direction vector to update with the result
  17969. * @param particle is the particle we are computed the direction for
  17970. */
  17971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17972. /**
  17973. * Called by the particle System when the position is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param positionToUpdate is the position vector to update with the result
  17976. * @param particle is the particle we are computed the position for
  17977. */
  17978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Clones the current emitter and returns a copy of it
  17981. * @returns the new emitter
  17982. */
  17983. clone(): HemisphericParticleEmitter;
  17984. /**
  17985. * Called by the GPUParticleSystem to setup the update shader
  17986. * @param effect defines the update shader
  17987. */
  17988. applyToShader(effect: Effect): void;
  17989. /**
  17990. * Returns a string to use to update the GPU particles update shader
  17991. * @returns a string containng the defines string
  17992. */
  17993. getEffectDefines(): string;
  17994. /**
  17995. * Returns the string "HemisphericParticleEmitter"
  17996. * @returns a string containing the class name
  17997. */
  17998. getClassName(): string;
  17999. /**
  18000. * Serializes the particle system to a JSON object.
  18001. * @returns the JSON object
  18002. */
  18003. serialize(): any;
  18004. /**
  18005. * Parse properties from a JSON object
  18006. * @param serializationObject defines the JSON object
  18007. */
  18008. parse(serializationObject: any): void;
  18009. }
  18010. }
  18011. declare module BABYLON {
  18012. /**
  18013. * Particle emitter emitting particles from a point.
  18014. * It emits the particles randomly between 2 given directions.
  18015. */
  18016. export class PointParticleEmitter implements IParticleEmitterType {
  18017. /**
  18018. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18019. */
  18020. direction1: Vector3;
  18021. /**
  18022. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18023. */
  18024. direction2: Vector3;
  18025. /**
  18026. * Creates a new instance PointParticleEmitter
  18027. */
  18028. constructor();
  18029. /**
  18030. * Called by the particle System when the direction is computed for the created particle.
  18031. * @param worldMatrix is the world matrix of the particle system
  18032. * @param directionToUpdate is the direction vector to update with the result
  18033. * @param particle is the particle we are computed the direction for
  18034. */
  18035. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18036. /**
  18037. * Called by the particle System when the position is computed for the created particle.
  18038. * @param worldMatrix is the world matrix of the particle system
  18039. * @param positionToUpdate is the position vector to update with the result
  18040. * @param particle is the particle we are computed the position for
  18041. */
  18042. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18043. /**
  18044. * Clones the current emitter and returns a copy of it
  18045. * @returns the new emitter
  18046. */
  18047. clone(): PointParticleEmitter;
  18048. /**
  18049. * Called by the GPUParticleSystem to setup the update shader
  18050. * @param effect defines the update shader
  18051. */
  18052. applyToShader(effect: Effect): void;
  18053. /**
  18054. * Returns a string to use to update the GPU particles update shader
  18055. * @returns a string containng the defines string
  18056. */
  18057. getEffectDefines(): string;
  18058. /**
  18059. * Returns the string "PointParticleEmitter"
  18060. * @returns a string containing the class name
  18061. */
  18062. getClassName(): string;
  18063. /**
  18064. * Serializes the particle system to a JSON object.
  18065. * @returns the JSON object
  18066. */
  18067. serialize(): any;
  18068. /**
  18069. * Parse properties from a JSON object
  18070. * @param serializationObject defines the JSON object
  18071. */
  18072. parse(serializationObject: any): void;
  18073. }
  18074. }
  18075. declare module BABYLON {
  18076. /**
  18077. * Particle emitter emitting particles from the inside of a sphere.
  18078. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18079. */
  18080. export class SphereParticleEmitter implements IParticleEmitterType {
  18081. /**
  18082. * The radius of the emission sphere.
  18083. */
  18084. radius: number;
  18085. /**
  18086. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18087. */
  18088. radiusRange: number;
  18089. /**
  18090. * How much to randomize the particle direction [0-1].
  18091. */
  18092. directionRandomizer: number;
  18093. /**
  18094. * Creates a new instance SphereParticleEmitter
  18095. * @param radius the radius of the emission sphere (1 by default)
  18096. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18097. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18098. */
  18099. constructor(
  18100. /**
  18101. * The radius of the emission sphere.
  18102. */
  18103. radius?: number,
  18104. /**
  18105. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18106. */
  18107. radiusRange?: number,
  18108. /**
  18109. * How much to randomize the particle direction [0-1].
  18110. */
  18111. directionRandomizer?: number);
  18112. /**
  18113. * Called by the particle System when the direction is computed for the created particle.
  18114. * @param worldMatrix is the world matrix of the particle system
  18115. * @param directionToUpdate is the direction vector to update with the result
  18116. * @param particle is the particle we are computed the direction for
  18117. */
  18118. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18119. /**
  18120. * Called by the particle System when the position is computed for the created particle.
  18121. * @param worldMatrix is the world matrix of the particle system
  18122. * @param positionToUpdate is the position vector to update with the result
  18123. * @param particle is the particle we are computed the position for
  18124. */
  18125. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18126. /**
  18127. * Clones the current emitter and returns a copy of it
  18128. * @returns the new emitter
  18129. */
  18130. clone(): SphereParticleEmitter;
  18131. /**
  18132. * Called by the GPUParticleSystem to setup the update shader
  18133. * @param effect defines the update shader
  18134. */
  18135. applyToShader(effect: Effect): void;
  18136. /**
  18137. * Returns a string to use to update the GPU particles update shader
  18138. * @returns a string containng the defines string
  18139. */
  18140. getEffectDefines(): string;
  18141. /**
  18142. * Returns the string "SphereParticleEmitter"
  18143. * @returns a string containing the class name
  18144. */
  18145. getClassName(): string;
  18146. /**
  18147. * Serializes the particle system to a JSON object.
  18148. * @returns the JSON object
  18149. */
  18150. serialize(): any;
  18151. /**
  18152. * Parse properties from a JSON object
  18153. * @param serializationObject defines the JSON object
  18154. */
  18155. parse(serializationObject: any): void;
  18156. }
  18157. /**
  18158. * Particle emitter emitting particles from the inside of a sphere.
  18159. * It emits the particles randomly between two vectors.
  18160. */
  18161. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18162. /**
  18163. * The min limit of the emission direction.
  18164. */
  18165. direction1: Vector3;
  18166. /**
  18167. * The max limit of the emission direction.
  18168. */
  18169. direction2: Vector3;
  18170. /**
  18171. * Creates a new instance SphereDirectedParticleEmitter
  18172. * @param radius the radius of the emission sphere (1 by default)
  18173. * @param direction1 the min limit of the emission direction (up vector by default)
  18174. * @param direction2 the max limit of the emission direction (up vector by default)
  18175. */
  18176. constructor(radius?: number,
  18177. /**
  18178. * The min limit of the emission direction.
  18179. */
  18180. direction1?: Vector3,
  18181. /**
  18182. * The max limit of the emission direction.
  18183. */
  18184. direction2?: Vector3);
  18185. /**
  18186. * Called by the particle System when the direction is computed for the created particle.
  18187. * @param worldMatrix is the world matrix of the particle system
  18188. * @param directionToUpdate is the direction vector to update with the result
  18189. * @param particle is the particle we are computed the direction for
  18190. */
  18191. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18192. /**
  18193. * Clones the current emitter and returns a copy of it
  18194. * @returns the new emitter
  18195. */
  18196. clone(): SphereDirectedParticleEmitter;
  18197. /**
  18198. * Called by the GPUParticleSystem to setup the update shader
  18199. * @param effect defines the update shader
  18200. */
  18201. applyToShader(effect: Effect): void;
  18202. /**
  18203. * Returns a string to use to update the GPU particles update shader
  18204. * @returns a string containng the defines string
  18205. */
  18206. getEffectDefines(): string;
  18207. /**
  18208. * Returns the string "SphereDirectedParticleEmitter"
  18209. * @returns a string containing the class name
  18210. */
  18211. getClassName(): string;
  18212. /**
  18213. * Serializes the particle system to a JSON object.
  18214. * @returns the JSON object
  18215. */
  18216. serialize(): any;
  18217. /**
  18218. * Parse properties from a JSON object
  18219. * @param serializationObject defines the JSON object
  18220. */
  18221. parse(serializationObject: any): void;
  18222. }
  18223. }
  18224. declare module BABYLON {
  18225. /**
  18226. * Interface representing a particle system in Babylon.js.
  18227. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18228. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18229. */
  18230. export interface IParticleSystem {
  18231. /**
  18232. * List of animations used by the particle system.
  18233. */
  18234. animations: Animation[];
  18235. /**
  18236. * The id of the Particle system.
  18237. */
  18238. id: string;
  18239. /**
  18240. * The name of the Particle system.
  18241. */
  18242. name: string;
  18243. /**
  18244. * The emitter represents the Mesh or position we are attaching the particle system to.
  18245. */
  18246. emitter: Nullable<AbstractMesh | Vector3>;
  18247. /**
  18248. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18249. */
  18250. isBillboardBased: boolean;
  18251. /**
  18252. * The rendering group used by the Particle system to chose when to render.
  18253. */
  18254. renderingGroupId: number;
  18255. /**
  18256. * The layer mask we are rendering the particles through.
  18257. */
  18258. layerMask: number;
  18259. /**
  18260. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18261. */
  18262. updateSpeed: number;
  18263. /**
  18264. * The amount of time the particle system is running (depends of the overall update speed).
  18265. */
  18266. targetStopDuration: number;
  18267. /**
  18268. * The texture used to render each particle. (this can be a spritesheet)
  18269. */
  18270. particleTexture: Nullable<Texture>;
  18271. /**
  18272. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18273. */
  18274. blendMode: number;
  18275. /**
  18276. * Minimum life time of emitting particles.
  18277. */
  18278. minLifeTime: number;
  18279. /**
  18280. * Maximum life time of emitting particles.
  18281. */
  18282. maxLifeTime: number;
  18283. /**
  18284. * Minimum Size of emitting particles.
  18285. */
  18286. minSize: number;
  18287. /**
  18288. * Maximum Size of emitting particles.
  18289. */
  18290. maxSize: number;
  18291. /**
  18292. * Minimum scale of emitting particles on X axis.
  18293. */
  18294. minScaleX: number;
  18295. /**
  18296. * Maximum scale of emitting particles on X axis.
  18297. */
  18298. maxScaleX: number;
  18299. /**
  18300. * Minimum scale of emitting particles on Y axis.
  18301. */
  18302. minScaleY: number;
  18303. /**
  18304. * Maximum scale of emitting particles on Y axis.
  18305. */
  18306. maxScaleY: number;
  18307. /**
  18308. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18309. */
  18310. color1: Color4;
  18311. /**
  18312. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18313. */
  18314. color2: Color4;
  18315. /**
  18316. * Color the particle will have at the end of its lifetime.
  18317. */
  18318. colorDead: Color4;
  18319. /**
  18320. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18321. */
  18322. emitRate: number;
  18323. /**
  18324. * You can use gravity if you want to give an orientation to your particles.
  18325. */
  18326. gravity: Vector3;
  18327. /**
  18328. * Minimum power of emitting particles.
  18329. */
  18330. minEmitPower: number;
  18331. /**
  18332. * Maximum power of emitting particles.
  18333. */
  18334. maxEmitPower: number;
  18335. /**
  18336. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18337. */
  18338. minAngularSpeed: number;
  18339. /**
  18340. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18341. */
  18342. maxAngularSpeed: number;
  18343. /**
  18344. * Gets or sets the minimal initial rotation in radians.
  18345. */
  18346. minInitialRotation: number;
  18347. /**
  18348. * Gets or sets the maximal initial rotation in radians.
  18349. */
  18350. maxInitialRotation: number;
  18351. /**
  18352. * The particle emitter type defines the emitter used by the particle system.
  18353. * It can be for example box, sphere, or cone...
  18354. */
  18355. particleEmitterType: Nullable<IParticleEmitterType>;
  18356. /**
  18357. * Defines the delay in milliseconds before starting the system (0 by default)
  18358. */
  18359. startDelay: number;
  18360. /**
  18361. * 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
  18362. */
  18363. preWarmCycles: number;
  18364. /**
  18365. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18366. */
  18367. preWarmStepOffset: number;
  18368. /**
  18369. * 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)
  18370. */
  18371. spriteCellChangeSpeed: number;
  18372. /**
  18373. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18374. */
  18375. startSpriteCellID: number;
  18376. /**
  18377. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18378. */
  18379. endSpriteCellID: number;
  18380. /**
  18381. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18382. */
  18383. spriteCellWidth: number;
  18384. /**
  18385. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18386. */
  18387. spriteCellHeight: number;
  18388. /**
  18389. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18390. */
  18391. spriteRandomStartCell: boolean;
  18392. /**
  18393. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18394. */
  18395. isAnimationSheetEnabled: boolean;
  18396. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18397. translationPivot: Vector2;
  18398. /**
  18399. * Gets or sets a texture used to add random noise to particle positions
  18400. */
  18401. noiseTexture: Nullable<BaseTexture>;
  18402. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18403. noiseStrength: Vector3;
  18404. /**
  18405. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18406. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18407. */
  18408. billboardMode: number;
  18409. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18410. limitVelocityDamping: number;
  18411. /**
  18412. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18413. */
  18414. beginAnimationOnStart: boolean;
  18415. /**
  18416. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18417. */
  18418. beginAnimationFrom: number;
  18419. /**
  18420. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18421. */
  18422. beginAnimationTo: number;
  18423. /**
  18424. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18425. */
  18426. beginAnimationLoop: boolean;
  18427. /**
  18428. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18429. */
  18430. disposeOnStop: boolean;
  18431. /**
  18432. * Gets the maximum number of particles active at the same time.
  18433. * @returns The max number of active particles.
  18434. */
  18435. getCapacity(): number;
  18436. /**
  18437. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18438. * @returns True if it has been started, otherwise false.
  18439. */
  18440. isStarted(): boolean;
  18441. /**
  18442. * Animates the particle system for this frame.
  18443. */
  18444. animate(): void;
  18445. /**
  18446. * Renders the particle system in its current state.
  18447. * @returns the current number of particles
  18448. */
  18449. render(): number;
  18450. /**
  18451. * Dispose the particle system and frees its associated resources.
  18452. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18453. */
  18454. dispose(disposeTexture?: boolean): void;
  18455. /**
  18456. * Clones the particle system.
  18457. * @param name The name of the cloned object
  18458. * @param newEmitter The new emitter to use
  18459. * @returns the cloned particle system
  18460. */
  18461. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18462. /**
  18463. * Serializes the particle system to a JSON object.
  18464. * @returns the JSON object
  18465. */
  18466. serialize(): any;
  18467. /**
  18468. * Rebuild the particle system
  18469. */
  18470. rebuild(): void;
  18471. /**
  18472. * Starts the particle system and begins to emit
  18473. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18474. */
  18475. start(delay?: number): void;
  18476. /**
  18477. * Stops the particle system.
  18478. */
  18479. stop(): void;
  18480. /**
  18481. * Remove all active particles
  18482. */
  18483. reset(): void;
  18484. /**
  18485. * Is this system ready to be used/rendered
  18486. * @return true if the system is ready
  18487. */
  18488. isReady(): boolean;
  18489. /**
  18490. * Adds a new color gradient
  18491. * @param gradient defines the gradient to use (between 0 and 1)
  18492. * @param color1 defines the color to affect to the specified gradient
  18493. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18494. * @returns the current particle system
  18495. */
  18496. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18497. /**
  18498. * Remove a specific color gradient
  18499. * @param gradient defines the gradient to remove
  18500. * @returns the current particle system
  18501. */
  18502. removeColorGradient(gradient: number): IParticleSystem;
  18503. /**
  18504. * Adds a new size gradient
  18505. * @param gradient defines the gradient to use (between 0 and 1)
  18506. * @param factor defines the size factor to affect to the specified gradient
  18507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18508. * @returns the current particle system
  18509. */
  18510. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18511. /**
  18512. * Remove a specific size gradient
  18513. * @param gradient defines the gradient to remove
  18514. * @returns the current particle system
  18515. */
  18516. removeSizeGradient(gradient: number): IParticleSystem;
  18517. /**
  18518. * Gets the current list of color gradients.
  18519. * You must use addColorGradient and removeColorGradient to udpate this list
  18520. * @returns the list of color gradients
  18521. */
  18522. getColorGradients(): Nullable<Array<ColorGradient>>;
  18523. /**
  18524. * Gets the current list of size gradients.
  18525. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18526. * @returns the list of size gradients
  18527. */
  18528. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18529. /**
  18530. * Gets the current list of angular speed gradients.
  18531. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18532. * @returns the list of angular speed gradients
  18533. */
  18534. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18535. /**
  18536. * Adds a new angular speed gradient
  18537. * @param gradient defines the gradient to use (between 0 and 1)
  18538. * @param factor defines the angular speed to affect to the specified gradient
  18539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18540. * @returns the current particle system
  18541. */
  18542. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18543. /**
  18544. * Remove a specific angular speed gradient
  18545. * @param gradient defines the gradient to remove
  18546. * @returns the current particle system
  18547. */
  18548. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18549. /**
  18550. * Gets the current list of velocity gradients.
  18551. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18552. * @returns the list of velocity gradients
  18553. */
  18554. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18555. /**
  18556. * Adds a new velocity gradient
  18557. * @param gradient defines the gradient to use (between 0 and 1)
  18558. * @param factor defines the velocity to affect to the specified gradient
  18559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18560. * @returns the current particle system
  18561. */
  18562. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18563. /**
  18564. * Remove a specific velocity gradient
  18565. * @param gradient defines the gradient to remove
  18566. * @returns the current particle system
  18567. */
  18568. removeVelocityGradient(gradient: number): IParticleSystem;
  18569. /**
  18570. * Gets the current list of limit velocity gradients.
  18571. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18572. * @returns the list of limit velocity gradients
  18573. */
  18574. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18575. /**
  18576. * Adds a new limit velocity gradient
  18577. * @param gradient defines the gradient to use (between 0 and 1)
  18578. * @param factor defines the limit velocity to affect to the specified gradient
  18579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18580. * @returns the current particle system
  18581. */
  18582. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18583. /**
  18584. * Remove a specific limit velocity gradient
  18585. * @param gradient defines the gradient to remove
  18586. * @returns the current particle system
  18587. */
  18588. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18589. /**
  18590. * Adds a new drag gradient
  18591. * @param gradient defines the gradient to use (between 0 and 1)
  18592. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18597. /**
  18598. * Remove a specific drag gradient
  18599. * @param gradient defines the gradient to remove
  18600. * @returns the current particle system
  18601. */
  18602. removeDragGradient(gradient: number): IParticleSystem;
  18603. /**
  18604. * Gets the current list of drag gradients.
  18605. * You must use addDragGradient and removeDragGradient to udpate this list
  18606. * @returns the list of drag gradients
  18607. */
  18608. getDragGradients(): Nullable<Array<FactorGradient>>;
  18609. /**
  18610. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18611. * @param gradient defines the gradient to use (between 0 and 1)
  18612. * @param factor defines the emit rate to affect to the specified gradient
  18613. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18614. * @returns the current particle system
  18615. */
  18616. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18617. /**
  18618. * Remove a specific emit rate gradient
  18619. * @param gradient defines the gradient to remove
  18620. * @returns the current particle system
  18621. */
  18622. removeEmitRateGradient(gradient: number): IParticleSystem;
  18623. /**
  18624. * Gets the current list of emit rate gradients.
  18625. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18626. * @returns the list of emit rate gradients
  18627. */
  18628. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18629. /**
  18630. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18631. * @param gradient defines the gradient to use (between 0 and 1)
  18632. * @param factor defines the start size to affect to the specified gradient
  18633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18634. * @returns the current particle system
  18635. */
  18636. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18637. /**
  18638. * Remove a specific start size gradient
  18639. * @param gradient defines the gradient to remove
  18640. * @returns the current particle system
  18641. */
  18642. removeStartSizeGradient(gradient: number): IParticleSystem;
  18643. /**
  18644. * Gets the current list of start size gradients.
  18645. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18646. * @returns the list of start size gradients
  18647. */
  18648. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18649. /**
  18650. * Adds a new life time gradient
  18651. * @param gradient defines the gradient to use (between 0 and 1)
  18652. * @param factor defines the life time factor to affect to the specified gradient
  18653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18654. * @returns the current particle system
  18655. */
  18656. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18657. /**
  18658. * Remove a specific life time gradient
  18659. * @param gradient defines the gradient to remove
  18660. * @returns the current particle system
  18661. */
  18662. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18663. /**
  18664. * Gets the current list of life time gradients.
  18665. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18666. * @returns the list of life time gradients
  18667. */
  18668. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18669. /**
  18670. * Gets the current list of color gradients.
  18671. * You must use addColorGradient and removeColorGradient to udpate this list
  18672. * @returns the list of color gradients
  18673. */
  18674. getColorGradients(): Nullable<Array<ColorGradient>>;
  18675. /**
  18676. * Adds a new ramp gradient used to remap particle colors
  18677. * @param gradient defines the gradient to use (between 0 and 1)
  18678. * @param color defines the color to affect to the specified gradient
  18679. * @returns the current particle system
  18680. */
  18681. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18682. /**
  18683. * Gets the current list of ramp gradients.
  18684. * You must use addRampGradient and removeRampGradient to udpate this list
  18685. * @returns the list of ramp gradients
  18686. */
  18687. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18688. /** Gets or sets a boolean indicating that ramp gradients must be used
  18689. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18690. */
  18691. useRampGradients: boolean;
  18692. /**
  18693. * Adds a new color remap gradient
  18694. * @param gradient defines the gradient to use (between 0 and 1)
  18695. * @param min defines the color remap minimal range
  18696. * @param max defines the color remap maximal range
  18697. * @returns the current particle system
  18698. */
  18699. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18700. /**
  18701. * Gets the current list of color remap gradients.
  18702. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18703. * @returns the list of color remap gradients
  18704. */
  18705. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18706. /**
  18707. * Adds a new alpha remap gradient
  18708. * @param gradient defines the gradient to use (between 0 and 1)
  18709. * @param min defines the alpha remap minimal range
  18710. * @param max defines the alpha remap maximal range
  18711. * @returns the current particle system
  18712. */
  18713. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18714. /**
  18715. * Gets the current list of alpha remap gradients.
  18716. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18717. * @returns the list of alpha remap gradients
  18718. */
  18719. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18720. /**
  18721. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18722. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18723. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18724. * @returns the emitter
  18725. */
  18726. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18727. /**
  18728. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18729. * @param radius The radius of the hemisphere to emit from
  18730. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18731. * @returns the emitter
  18732. */
  18733. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18734. /**
  18735. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18736. * @param radius The radius of the sphere to emit from
  18737. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18738. * @returns the emitter
  18739. */
  18740. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18741. /**
  18742. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18743. * @param radius The radius of the sphere to emit from
  18744. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18745. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18746. * @returns the emitter
  18747. */
  18748. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18749. /**
  18750. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18751. * @param radius The radius of the emission cylinder
  18752. * @param height The height of the emission cylinder
  18753. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18754. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18755. * @returns the emitter
  18756. */
  18757. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18758. /**
  18759. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18760. * @param radius The radius of the cylinder to emit from
  18761. * @param height The height of the emission cylinder
  18762. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18765. * @returns the emitter
  18766. */
  18767. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18768. /**
  18769. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18770. * @param radius The radius of the cone to emit from
  18771. * @param angle The base angle of the cone
  18772. * @returns the emitter
  18773. */
  18774. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18775. /**
  18776. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18777. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18778. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18779. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18780. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18781. * @returns the emitter
  18782. */
  18783. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18784. /**
  18785. * Get hosting scene
  18786. * @returns the scene
  18787. */
  18788. getScene(): Scene;
  18789. }
  18790. }
  18791. declare module BABYLON {
  18792. /**
  18793. * Creates an instance based on a source mesh.
  18794. */
  18795. export class InstancedMesh extends AbstractMesh {
  18796. private _sourceMesh;
  18797. private _currentLOD;
  18798. /** @hidden */
  18799. _indexInSourceMeshInstanceArray: number;
  18800. constructor(name: string, source: Mesh);
  18801. /**
  18802. * Returns the string "InstancedMesh".
  18803. */
  18804. getClassName(): string;
  18805. /** Gets the list of lights affecting that mesh */
  18806. readonly lightSources: Light[];
  18807. _resyncLightSources(): void;
  18808. _resyncLighSource(light: Light): void;
  18809. _removeLightSource(light: Light, dispose: boolean): void;
  18810. /**
  18811. * If the source mesh receives shadows
  18812. */
  18813. readonly receiveShadows: boolean;
  18814. /**
  18815. * The material of the source mesh
  18816. */
  18817. readonly material: Nullable<Material>;
  18818. /**
  18819. * Visibility of the source mesh
  18820. */
  18821. readonly visibility: number;
  18822. /**
  18823. * Skeleton of the source mesh
  18824. */
  18825. readonly skeleton: Nullable<Skeleton>;
  18826. /**
  18827. * Rendering ground id of the source mesh
  18828. */
  18829. renderingGroupId: number;
  18830. /**
  18831. * Returns the total number of vertices (integer).
  18832. */
  18833. getTotalVertices(): number;
  18834. /**
  18835. * Returns a positive integer : the total number of indices in this mesh geometry.
  18836. * @returns the numner of indices or zero if the mesh has no geometry.
  18837. */
  18838. getTotalIndices(): number;
  18839. /**
  18840. * The source mesh of the instance
  18841. */
  18842. readonly sourceMesh: Mesh;
  18843. /**
  18844. * Is this node ready to be used/rendered
  18845. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18846. * @return {boolean} is it ready
  18847. */
  18848. isReady(completeCheck?: boolean): boolean;
  18849. /**
  18850. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18851. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18852. * @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.
  18853. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18854. */
  18855. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18856. /**
  18857. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18858. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18859. * The `data` are either a numeric array either a Float32Array.
  18860. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18861. * 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).
  18862. * Note that a new underlying VertexBuffer object is created each call.
  18863. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18864. *
  18865. * Possible `kind` values :
  18866. * - VertexBuffer.PositionKind
  18867. * - VertexBuffer.UVKind
  18868. * - VertexBuffer.UV2Kind
  18869. * - VertexBuffer.UV3Kind
  18870. * - VertexBuffer.UV4Kind
  18871. * - VertexBuffer.UV5Kind
  18872. * - VertexBuffer.UV6Kind
  18873. * - VertexBuffer.ColorKind
  18874. * - VertexBuffer.MatricesIndicesKind
  18875. * - VertexBuffer.MatricesIndicesExtraKind
  18876. * - VertexBuffer.MatricesWeightsKind
  18877. * - VertexBuffer.MatricesWeightsExtraKind
  18878. *
  18879. * Returns the Mesh.
  18880. */
  18881. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18882. /**
  18883. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18884. * If the mesh has no geometry, it is simply returned as it is.
  18885. * The `data` are either a numeric array either a Float32Array.
  18886. * No new underlying VertexBuffer object is created.
  18887. * 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.
  18888. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18889. *
  18890. * Possible `kind` values :
  18891. * - VertexBuffer.PositionKind
  18892. * - VertexBuffer.UVKind
  18893. * - VertexBuffer.UV2Kind
  18894. * - VertexBuffer.UV3Kind
  18895. * - VertexBuffer.UV4Kind
  18896. * - VertexBuffer.UV5Kind
  18897. * - VertexBuffer.UV6Kind
  18898. * - VertexBuffer.ColorKind
  18899. * - VertexBuffer.MatricesIndicesKind
  18900. * - VertexBuffer.MatricesIndicesExtraKind
  18901. * - VertexBuffer.MatricesWeightsKind
  18902. * - VertexBuffer.MatricesWeightsExtraKind
  18903. *
  18904. * Returns the Mesh.
  18905. */
  18906. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18907. /**
  18908. * Sets the mesh indices.
  18909. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18910. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18911. * This method creates a new index buffer each call.
  18912. * Returns the Mesh.
  18913. */
  18914. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18915. /**
  18916. * Boolean : True if the mesh owns the requested kind of data.
  18917. */
  18918. isVerticesDataPresent(kind: string): boolean;
  18919. /**
  18920. * Returns an array of indices (IndicesArray).
  18921. */
  18922. getIndices(): Nullable<IndicesArray>;
  18923. readonly _positions: Nullable<Vector3[]>;
  18924. /**
  18925. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18926. * This means the mesh underlying bounding box and sphere are recomputed.
  18927. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18928. * @returns the current mesh
  18929. */
  18930. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18931. /** @hidden */
  18932. _preActivate(): InstancedMesh;
  18933. /** @hidden */
  18934. _activate(renderId: number, intermediateRendering: boolean): boolean;
  18935. /** @hidden */
  18936. _postActivate(): void;
  18937. getWorldMatrix(): Matrix;
  18938. readonly isAnInstance: boolean;
  18939. /**
  18940. * Returns the current associated LOD AbstractMesh.
  18941. */
  18942. getLOD(camera: Camera): AbstractMesh;
  18943. /** @hidden */
  18944. _syncSubMeshes(): InstancedMesh;
  18945. /** @hidden */
  18946. _generatePointsArray(): boolean;
  18947. /**
  18948. * Creates a new InstancedMesh from the current mesh.
  18949. * - name (string) : the cloned mesh name
  18950. * - newParent (optional Node) : the optional Node to parent the clone to.
  18951. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18952. *
  18953. * Returns the clone.
  18954. */
  18955. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18956. /**
  18957. * Disposes the InstancedMesh.
  18958. * Returns nothing.
  18959. */
  18960. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18961. }
  18962. }
  18963. declare module BABYLON {
  18964. /**
  18965. * Defines the options associated with the creation of a shader material.
  18966. */
  18967. export interface IShaderMaterialOptions {
  18968. /**
  18969. * Does the material work in alpha blend mode
  18970. */
  18971. needAlphaBlending: boolean;
  18972. /**
  18973. * Does the material work in alpha test mode
  18974. */
  18975. needAlphaTesting: boolean;
  18976. /**
  18977. * The list of attribute names used in the shader
  18978. */
  18979. attributes: string[];
  18980. /**
  18981. * The list of unifrom names used in the shader
  18982. */
  18983. uniforms: string[];
  18984. /**
  18985. * The list of UBO names used in the shader
  18986. */
  18987. uniformBuffers: string[];
  18988. /**
  18989. * The list of sampler names used in the shader
  18990. */
  18991. samplers: string[];
  18992. /**
  18993. * The list of defines used in the shader
  18994. */
  18995. defines: string[];
  18996. }
  18997. /**
  18998. * 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.
  18999. *
  19000. * This returned material effects how the mesh will look based on the code in the shaders.
  19001. *
  19002. * @see http://doc.babylonjs.com/how_to/shader_material
  19003. */
  19004. export class ShaderMaterial extends Material {
  19005. private _shaderPath;
  19006. private _options;
  19007. private _textures;
  19008. private _textureArrays;
  19009. private _floats;
  19010. private _ints;
  19011. private _floatsArrays;
  19012. private _colors3;
  19013. private _colors3Arrays;
  19014. private _colors4;
  19015. private _colors4Arrays;
  19016. private _vectors2;
  19017. private _vectors3;
  19018. private _vectors4;
  19019. private _matrices;
  19020. private _matrices3x3;
  19021. private _matrices2x2;
  19022. private _vectors2Arrays;
  19023. private _vectors3Arrays;
  19024. private _vectors4Arrays;
  19025. private _cachedWorldViewMatrix;
  19026. private _cachedWorldViewProjectionMatrix;
  19027. private _renderId;
  19028. /**
  19029. * Instantiate a new shader material.
  19030. * 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.
  19031. * This returned material effects how the mesh will look based on the code in the shaders.
  19032. * @see http://doc.babylonjs.com/how_to/shader_material
  19033. * @param name Define the name of the material in the scene
  19034. * @param scene Define the scene the material belongs to
  19035. * @param shaderPath Defines the route to the shader code in one of three ways:
  19036. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19037. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19038. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19039. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19040. * @param options Define the options used to create the shader
  19041. */
  19042. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19043. /**
  19044. * Gets the options used to compile the shader.
  19045. * They can be modified to trigger a new compilation
  19046. */
  19047. readonly options: IShaderMaterialOptions;
  19048. /**
  19049. * Gets the current class name of the material e.g. "ShaderMaterial"
  19050. * Mainly use in serialization.
  19051. * @returns the class name
  19052. */
  19053. getClassName(): string;
  19054. /**
  19055. * Specifies if the material will require alpha blending
  19056. * @returns a boolean specifying if alpha blending is needed
  19057. */
  19058. needAlphaBlending(): boolean;
  19059. /**
  19060. * Specifies if this material should be rendered in alpha test mode
  19061. * @returns a boolean specifying if an alpha test is needed.
  19062. */
  19063. needAlphaTesting(): boolean;
  19064. private _checkUniform;
  19065. /**
  19066. * Set a texture in the shader.
  19067. * @param name Define the name of the uniform samplers as defined in the shader
  19068. * @param texture Define the texture to bind to this sampler
  19069. * @return the material itself allowing "fluent" like uniform updates
  19070. */
  19071. setTexture(name: string, texture: Texture): ShaderMaterial;
  19072. /**
  19073. * Set a texture array in the shader.
  19074. * @param name Define the name of the uniform sampler array as defined in the shader
  19075. * @param textures Define the list of textures to bind to this sampler
  19076. * @return the material itself allowing "fluent" like uniform updates
  19077. */
  19078. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19079. /**
  19080. * Set a float in the shader.
  19081. * @param name Define the name of the uniform as defined in the shader
  19082. * @param value Define the value to give to the uniform
  19083. * @return the material itself allowing "fluent" like uniform updates
  19084. */
  19085. setFloat(name: string, value: number): ShaderMaterial;
  19086. /**
  19087. * Set a int in the shader.
  19088. * @param name Define the name of the uniform as defined in the shader
  19089. * @param value Define the value to give to the uniform
  19090. * @return the material itself allowing "fluent" like uniform updates
  19091. */
  19092. setInt(name: string, value: number): ShaderMaterial;
  19093. /**
  19094. * Set an array of floats in the shader.
  19095. * @param name Define the name of the uniform as defined in the shader
  19096. * @param value Define the value to give to the uniform
  19097. * @return the material itself allowing "fluent" like uniform updates
  19098. */
  19099. setFloats(name: string, value: number[]): ShaderMaterial;
  19100. /**
  19101. * Set a vec3 in the shader from a Color3.
  19102. * @param name Define the name of the uniform as defined in the shader
  19103. * @param value Define the value to give to the uniform
  19104. * @return the material itself allowing "fluent" like uniform updates
  19105. */
  19106. setColor3(name: string, value: Color3): ShaderMaterial;
  19107. /**
  19108. * Set a vec3 array in the shader from a Color3 array.
  19109. * @param name Define the name of the uniform as defined in the shader
  19110. * @param value Define the value to give to the uniform
  19111. * @return the material itself allowing "fluent" like uniform updates
  19112. */
  19113. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19114. /**
  19115. * Set a vec4 in the shader from a Color4.
  19116. * @param name Define the name of the uniform as defined in the shader
  19117. * @param value Define the value to give to the uniform
  19118. * @return the material itself allowing "fluent" like uniform updates
  19119. */
  19120. setColor4(name: string, value: Color4): ShaderMaterial;
  19121. /**
  19122. * Set a vec4 array in the shader from a Color4 array.
  19123. * @param name Define the name of the uniform as defined in the shader
  19124. * @param value Define the value to give to the uniform
  19125. * @return the material itself allowing "fluent" like uniform updates
  19126. */
  19127. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19128. /**
  19129. * Set a vec2 in the shader from a Vector2.
  19130. * @param name Define the name of the uniform as defined in the shader
  19131. * @param value Define the value to give to the uniform
  19132. * @return the material itself allowing "fluent" like uniform updates
  19133. */
  19134. setVector2(name: string, value: Vector2): ShaderMaterial;
  19135. /**
  19136. * Set a vec3 in the shader from a Vector3.
  19137. * @param name Define the name of the uniform as defined in the shader
  19138. * @param value Define the value to give to the uniform
  19139. * @return the material itself allowing "fluent" like uniform updates
  19140. */
  19141. setVector3(name: string, value: Vector3): ShaderMaterial;
  19142. /**
  19143. * Set a vec4 in the shader from a Vector4.
  19144. * @param name Define the name of the uniform as defined in the shader
  19145. * @param value Define the value to give to the uniform
  19146. * @return the material itself allowing "fluent" like uniform updates
  19147. */
  19148. setVector4(name: string, value: Vector4): ShaderMaterial;
  19149. /**
  19150. * Set a mat4 in the shader from a Matrix.
  19151. * @param name Define the name of the uniform as defined in the shader
  19152. * @param value Define the value to give to the uniform
  19153. * @return the material itself allowing "fluent" like uniform updates
  19154. */
  19155. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19156. /**
  19157. * Set a mat3 in the shader from a Float32Array.
  19158. * @param name Define the name of the uniform as defined in the shader
  19159. * @param value Define the value to give to the uniform
  19160. * @return the material itself allowing "fluent" like uniform updates
  19161. */
  19162. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19163. /**
  19164. * Set a mat2 in the shader from a Float32Array.
  19165. * @param name Define the name of the uniform as defined in the shader
  19166. * @param value Define the value to give to the uniform
  19167. * @return the material itself allowing "fluent" like uniform updates
  19168. */
  19169. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19170. /**
  19171. * Set a vec2 array in the shader from a number array.
  19172. * @param name Define the name of the uniform as defined in the shader
  19173. * @param value Define the value to give to the uniform
  19174. * @return the material itself allowing "fluent" like uniform updates
  19175. */
  19176. setArray2(name: string, value: number[]): ShaderMaterial;
  19177. /**
  19178. * Set a vec3 array in the shader from a number array.
  19179. * @param name Define the name of the uniform as defined in the shader
  19180. * @param value Define the value to give to the uniform
  19181. * @return the material itself allowing "fluent" like uniform updates
  19182. */
  19183. setArray3(name: string, value: number[]): ShaderMaterial;
  19184. /**
  19185. * Set a vec4 array in the shader from a number array.
  19186. * @param name Define the name of the uniform as defined in the shader
  19187. * @param value Define the value to give to the uniform
  19188. * @return the material itself allowing "fluent" like uniform updates
  19189. */
  19190. setArray4(name: string, value: number[]): ShaderMaterial;
  19191. private _checkCache;
  19192. /**
  19193. * Specifies that the submesh is ready to be used
  19194. * @param mesh defines the mesh to check
  19195. * @param subMesh defines which submesh to check
  19196. * @param useInstances specifies that instances should be used
  19197. * @returns a boolean indicating that the submesh is ready or not
  19198. */
  19199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19200. /**
  19201. * Checks if the material is ready to render the requested mesh
  19202. * @param mesh Define the mesh to render
  19203. * @param useInstances Define whether or not the material is used with instances
  19204. * @returns true if ready, otherwise false
  19205. */
  19206. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19207. /**
  19208. * Binds the world matrix to the material
  19209. * @param world defines the world transformation matrix
  19210. */
  19211. bindOnlyWorldMatrix(world: Matrix): void;
  19212. /**
  19213. * Binds the material to the mesh
  19214. * @param world defines the world transformation matrix
  19215. * @param mesh defines the mesh to bind the material to
  19216. */
  19217. bind(world: Matrix, mesh?: Mesh): void;
  19218. /**
  19219. * Gets the active textures from the material
  19220. * @returns an array of textures
  19221. */
  19222. getActiveTextures(): BaseTexture[];
  19223. /**
  19224. * Specifies if the material uses a texture
  19225. * @param texture defines the texture to check against the material
  19226. * @returns a boolean specifying if the material uses the texture
  19227. */
  19228. hasTexture(texture: BaseTexture): boolean;
  19229. /**
  19230. * Makes a duplicate of the material, and gives it a new name
  19231. * @param name defines the new name for the duplicated material
  19232. * @returns the cloned material
  19233. */
  19234. clone(name: string): ShaderMaterial;
  19235. /**
  19236. * Disposes the material
  19237. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19238. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19239. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19240. */
  19241. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19242. /**
  19243. * Serializes this material in a JSON representation
  19244. * @returns the serialized material object
  19245. */
  19246. serialize(): any;
  19247. /**
  19248. * Creates a shader material from parsed shader material data
  19249. * @param source defines the JSON represnetation of the material
  19250. * @param scene defines the hosting scene
  19251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19252. * @returns a new material
  19253. */
  19254. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19255. }
  19256. }
  19257. declare module BABYLON {
  19258. /** @hidden */
  19259. export var colorPixelShader: {
  19260. name: string;
  19261. shader: string;
  19262. };
  19263. }
  19264. declare module BABYLON {
  19265. /** @hidden */
  19266. export var colorVertexShader: {
  19267. name: string;
  19268. shader: string;
  19269. };
  19270. }
  19271. declare module BABYLON {
  19272. /**
  19273. * Line mesh
  19274. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19275. */
  19276. export class LinesMesh extends Mesh {
  19277. /**
  19278. * If vertex color should be applied to the mesh
  19279. */
  19280. readonly useVertexColor?: boolean | undefined;
  19281. /**
  19282. * If vertex alpha should be applied to the mesh
  19283. */
  19284. readonly useVertexAlpha?: boolean | undefined;
  19285. /**
  19286. * Color of the line (Default: White)
  19287. */
  19288. color: Color3;
  19289. /**
  19290. * Alpha of the line (Default: 1)
  19291. */
  19292. alpha: number;
  19293. /**
  19294. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19295. * This margin is expressed in world space coordinates, so its value may vary.
  19296. * Default value is 0.1
  19297. */
  19298. intersectionThreshold: number;
  19299. private _colorShader;
  19300. private color4;
  19301. /**
  19302. * Creates a new LinesMesh
  19303. * @param name defines the name
  19304. * @param scene defines the hosting scene
  19305. * @param parent defines the parent mesh if any
  19306. * @param source defines the optional source LinesMesh used to clone data from
  19307. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19308. * When false, achieved by calling a clone(), also passing False.
  19309. * This will make creation of children, recursive.
  19310. * @param useVertexColor defines if this LinesMesh supports vertex color
  19311. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19312. */
  19313. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19314. /**
  19315. * If vertex color should be applied to the mesh
  19316. */
  19317. useVertexColor?: boolean | undefined,
  19318. /**
  19319. * If vertex alpha should be applied to the mesh
  19320. */
  19321. useVertexAlpha?: boolean | undefined);
  19322. private _addClipPlaneDefine;
  19323. private _removeClipPlaneDefine;
  19324. isReady(): boolean;
  19325. /**
  19326. * Returns the string "LineMesh"
  19327. */
  19328. getClassName(): string;
  19329. /**
  19330. * @hidden
  19331. */
  19332. /**
  19333. * @hidden
  19334. */
  19335. material: Material;
  19336. /**
  19337. * @hidden
  19338. */
  19339. readonly checkCollisions: boolean;
  19340. /** @hidden */
  19341. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19342. /** @hidden */
  19343. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19344. /**
  19345. * Disposes of the line mesh
  19346. * @param doNotRecurse If children should be disposed
  19347. */
  19348. dispose(doNotRecurse?: boolean): void;
  19349. /**
  19350. * Returns a new LineMesh object cloned from the current one.
  19351. */
  19352. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19353. /**
  19354. * Creates a new InstancedLinesMesh object from the mesh model.
  19355. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19356. * @param name defines the name of the new instance
  19357. * @returns a new InstancedLinesMesh
  19358. */
  19359. createInstance(name: string): InstancedLinesMesh;
  19360. }
  19361. /**
  19362. * Creates an instance based on a source LinesMesh
  19363. */
  19364. export class InstancedLinesMesh extends InstancedMesh {
  19365. /**
  19366. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19367. * This margin is expressed in world space coordinates, so its value may vary.
  19368. * Initilized with the intersectionThreshold value of the source LinesMesh
  19369. */
  19370. intersectionThreshold: number;
  19371. constructor(name: string, source: LinesMesh);
  19372. /**
  19373. * Returns the string "InstancedLinesMesh".
  19374. */
  19375. getClassName(): string;
  19376. }
  19377. }
  19378. declare module BABYLON {
  19379. /** @hidden */
  19380. export var linePixelShader: {
  19381. name: string;
  19382. shader: string;
  19383. };
  19384. }
  19385. declare module BABYLON {
  19386. /** @hidden */
  19387. export var lineVertexShader: {
  19388. name: string;
  19389. shader: string;
  19390. };
  19391. }
  19392. declare module BABYLON {
  19393. interface AbstractMesh {
  19394. /**
  19395. * Gets the edgesRenderer associated with the mesh
  19396. */
  19397. edgesRenderer: Nullable<EdgesRenderer>;
  19398. }
  19399. interface LinesMesh {
  19400. /**
  19401. * Enables the edge rendering mode on the mesh.
  19402. * This mode makes the mesh edges visible
  19403. * @param epsilon defines the maximal distance between two angles to detect a face
  19404. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19405. * @returns the currentAbstractMesh
  19406. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19407. */
  19408. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19409. }
  19410. interface InstancedLinesMesh {
  19411. /**
  19412. * Enables the edge rendering mode on the mesh.
  19413. * This mode makes the mesh edges visible
  19414. * @param epsilon defines the maximal distance between two angles to detect a face
  19415. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19416. * @returns the current InstancedLinesMesh
  19417. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19418. */
  19419. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19420. }
  19421. /**
  19422. * Defines the minimum contract an Edges renderer should follow.
  19423. */
  19424. export interface IEdgesRenderer extends IDisposable {
  19425. /**
  19426. * Gets or sets a boolean indicating if the edgesRenderer is active
  19427. */
  19428. isEnabled: boolean;
  19429. /**
  19430. * Renders the edges of the attached mesh,
  19431. */
  19432. render(): void;
  19433. /**
  19434. * Checks wether or not the edges renderer is ready to render.
  19435. * @return true if ready, otherwise false.
  19436. */
  19437. isReady(): boolean;
  19438. }
  19439. /**
  19440. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19441. */
  19442. export class EdgesRenderer implements IEdgesRenderer {
  19443. /**
  19444. * Define the size of the edges with an orthographic camera
  19445. */
  19446. edgesWidthScalerForOrthographic: number;
  19447. /**
  19448. * Define the size of the edges with a perspective camera
  19449. */
  19450. edgesWidthScalerForPerspective: number;
  19451. protected _source: AbstractMesh;
  19452. protected _linesPositions: number[];
  19453. protected _linesNormals: number[];
  19454. protected _linesIndices: number[];
  19455. protected _epsilon: number;
  19456. protected _indicesCount: number;
  19457. protected _lineShader: ShaderMaterial;
  19458. protected _ib: DataBuffer;
  19459. protected _buffers: {
  19460. [key: string]: Nullable<VertexBuffer>;
  19461. };
  19462. protected _checkVerticesInsteadOfIndices: boolean;
  19463. private _meshRebuildObserver;
  19464. private _meshDisposeObserver;
  19465. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19466. isEnabled: boolean;
  19467. /**
  19468. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19469. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19470. * @param source Mesh used to create edges
  19471. * @param epsilon sum of angles in adjacency to check for edge
  19472. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19473. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19474. */
  19475. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19476. protected _prepareRessources(): void;
  19477. /** @hidden */
  19478. _rebuild(): void;
  19479. /**
  19480. * Releases the required resources for the edges renderer
  19481. */
  19482. dispose(): void;
  19483. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19484. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19485. /**
  19486. * Checks if the pair of p0 and p1 is en edge
  19487. * @param faceIndex
  19488. * @param edge
  19489. * @param faceNormals
  19490. * @param p0
  19491. * @param p1
  19492. * @private
  19493. */
  19494. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19495. /**
  19496. * push line into the position, normal and index buffer
  19497. * @protected
  19498. */
  19499. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19500. /**
  19501. * Generates lines edges from adjacencjes
  19502. * @private
  19503. */
  19504. _generateEdgesLines(): void;
  19505. /**
  19506. * Checks wether or not the edges renderer is ready to render.
  19507. * @return true if ready, otherwise false.
  19508. */
  19509. isReady(): boolean;
  19510. /**
  19511. * Renders the edges of the attached mesh,
  19512. */
  19513. render(): void;
  19514. }
  19515. /**
  19516. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19517. */
  19518. export class LineEdgesRenderer extends EdgesRenderer {
  19519. /**
  19520. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19521. * @param source LineMesh used to generate edges
  19522. * @param epsilon not important (specified angle for edge detection)
  19523. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19524. */
  19525. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19526. /**
  19527. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19528. */
  19529. _generateEdgesLines(): void;
  19530. }
  19531. }
  19532. declare module BABYLON {
  19533. /**
  19534. * This represents the object necessary to create a rendering group.
  19535. * This is exclusively used and created by the rendering manager.
  19536. * To modify the behavior, you use the available helpers in your scene or meshes.
  19537. * @hidden
  19538. */
  19539. export class RenderingGroup {
  19540. index: number;
  19541. private static _zeroVector;
  19542. private _scene;
  19543. private _opaqueSubMeshes;
  19544. private _transparentSubMeshes;
  19545. private _alphaTestSubMeshes;
  19546. private _depthOnlySubMeshes;
  19547. private _particleSystems;
  19548. private _spriteManagers;
  19549. private _opaqueSortCompareFn;
  19550. private _alphaTestSortCompareFn;
  19551. private _transparentSortCompareFn;
  19552. private _renderOpaque;
  19553. private _renderAlphaTest;
  19554. private _renderTransparent;
  19555. /** @hidden */
  19556. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19557. onBeforeTransparentRendering: () => void;
  19558. /**
  19559. * Set the opaque sort comparison function.
  19560. * If null the sub meshes will be render in the order they were created
  19561. */
  19562. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19563. /**
  19564. * Set the alpha test sort comparison function.
  19565. * If null the sub meshes will be render in the order they were created
  19566. */
  19567. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19568. /**
  19569. * Set the transparent sort comparison function.
  19570. * If null the sub meshes will be render in the order they were created
  19571. */
  19572. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19573. /**
  19574. * Creates a new rendering group.
  19575. * @param index The rendering group index
  19576. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19577. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19578. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19579. */
  19580. 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>);
  19581. /**
  19582. * Render all the sub meshes contained in the group.
  19583. * @param customRenderFunction Used to override the default render behaviour of the group.
  19584. * @returns true if rendered some submeshes.
  19585. */
  19586. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19587. /**
  19588. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19589. * @param subMeshes The submeshes to render
  19590. */
  19591. private renderOpaqueSorted;
  19592. /**
  19593. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19594. * @param subMeshes The submeshes to render
  19595. */
  19596. private renderAlphaTestSorted;
  19597. /**
  19598. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19599. * @param subMeshes The submeshes to render
  19600. */
  19601. private renderTransparentSorted;
  19602. /**
  19603. * Renders the submeshes in a specified order.
  19604. * @param subMeshes The submeshes to sort before render
  19605. * @param sortCompareFn The comparison function use to sort
  19606. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19607. * @param transparent Specifies to activate blending if true
  19608. */
  19609. private static renderSorted;
  19610. /**
  19611. * Renders the submeshes in the order they were dispatched (no sort applied).
  19612. * @param subMeshes The submeshes to render
  19613. */
  19614. private static renderUnsorted;
  19615. /**
  19616. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19617. * are rendered back to front if in the same alpha index.
  19618. *
  19619. * @param a The first submesh
  19620. * @param b The second submesh
  19621. * @returns The result of the comparison
  19622. */
  19623. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19624. /**
  19625. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19626. * are rendered back to front.
  19627. *
  19628. * @param a The first submesh
  19629. * @param b The second submesh
  19630. * @returns The result of the comparison
  19631. */
  19632. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19633. /**
  19634. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19635. * are rendered front to back (prevent overdraw).
  19636. *
  19637. * @param a The first submesh
  19638. * @param b The second submesh
  19639. * @returns The result of the comparison
  19640. */
  19641. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19642. /**
  19643. * Resets the different lists of submeshes to prepare a new frame.
  19644. */
  19645. prepare(): void;
  19646. dispose(): void;
  19647. /**
  19648. * Inserts the submesh in its correct queue depending on its material.
  19649. * @param subMesh The submesh to dispatch
  19650. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19651. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19652. */
  19653. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19654. dispatchSprites(spriteManager: ISpriteManager): void;
  19655. dispatchParticles(particleSystem: IParticleSystem): void;
  19656. private _renderParticles;
  19657. private _renderSprites;
  19658. }
  19659. }
  19660. declare module BABYLON {
  19661. /**
  19662. * Interface describing the different options available in the rendering manager
  19663. * regarding Auto Clear between groups.
  19664. */
  19665. export interface IRenderingManagerAutoClearSetup {
  19666. /**
  19667. * Defines whether or not autoclear is enable.
  19668. */
  19669. autoClear: boolean;
  19670. /**
  19671. * Defines whether or not to autoclear the depth buffer.
  19672. */
  19673. depth: boolean;
  19674. /**
  19675. * Defines whether or not to autoclear the stencil buffer.
  19676. */
  19677. stencil: boolean;
  19678. }
  19679. /**
  19680. * This class is used by the onRenderingGroupObservable
  19681. */
  19682. export class RenderingGroupInfo {
  19683. /**
  19684. * The Scene that being rendered
  19685. */
  19686. scene: Scene;
  19687. /**
  19688. * The camera currently used for the rendering pass
  19689. */
  19690. camera: Nullable<Camera>;
  19691. /**
  19692. * The ID of the renderingGroup being processed
  19693. */
  19694. renderingGroupId: number;
  19695. }
  19696. /**
  19697. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19698. * It is enable to manage the different groups as well as the different necessary sort functions.
  19699. * This should not be used directly aside of the few static configurations
  19700. */
  19701. export class RenderingManager {
  19702. /**
  19703. * The max id used for rendering groups (not included)
  19704. */
  19705. static MAX_RENDERINGGROUPS: number;
  19706. /**
  19707. * The min id used for rendering groups (included)
  19708. */
  19709. static MIN_RENDERINGGROUPS: number;
  19710. /**
  19711. * Used to globally prevent autoclearing scenes.
  19712. */
  19713. static AUTOCLEAR: boolean;
  19714. /**
  19715. * @hidden
  19716. */
  19717. _useSceneAutoClearSetup: boolean;
  19718. private _scene;
  19719. private _renderingGroups;
  19720. private _depthStencilBufferAlreadyCleaned;
  19721. private _autoClearDepthStencil;
  19722. private _customOpaqueSortCompareFn;
  19723. private _customAlphaTestSortCompareFn;
  19724. private _customTransparentSortCompareFn;
  19725. private _renderingGroupInfo;
  19726. /**
  19727. * Instantiates a new rendering group for a particular scene
  19728. * @param scene Defines the scene the groups belongs to
  19729. */
  19730. constructor(scene: Scene);
  19731. private _clearDepthStencilBuffer;
  19732. /**
  19733. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19734. * @hidden
  19735. */
  19736. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19737. /**
  19738. * Resets the different information of the group to prepare a new frame
  19739. * @hidden
  19740. */
  19741. reset(): void;
  19742. /**
  19743. * Dispose and release the group and its associated resources.
  19744. * @hidden
  19745. */
  19746. dispose(): void;
  19747. /**
  19748. * Clear the info related to rendering groups preventing retention points during dispose.
  19749. */
  19750. freeRenderingGroups(): void;
  19751. private _prepareRenderingGroup;
  19752. /**
  19753. * Add a sprite manager to the rendering manager in order to render it this frame.
  19754. * @param spriteManager Define the sprite manager to render
  19755. */
  19756. dispatchSprites(spriteManager: ISpriteManager): void;
  19757. /**
  19758. * Add a particle system to the rendering manager in order to render it this frame.
  19759. * @param particleSystem Define the particle system to render
  19760. */
  19761. dispatchParticles(particleSystem: IParticleSystem): void;
  19762. /**
  19763. * Add a submesh to the manager in order to render it this frame
  19764. * @param subMesh The submesh to dispatch
  19765. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19766. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19767. */
  19768. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19769. /**
  19770. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19771. * This allowed control for front to back rendering or reversly depending of the special needs.
  19772. *
  19773. * @param renderingGroupId The rendering group id corresponding to its index
  19774. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19775. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19776. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19777. */
  19778. 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;
  19779. /**
  19780. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19781. *
  19782. * @param renderingGroupId The rendering group id corresponding to its index
  19783. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19784. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19785. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19786. */
  19787. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19788. /**
  19789. * Gets the current auto clear configuration for one rendering group of the rendering
  19790. * manager.
  19791. * @param index the rendering group index to get the information for
  19792. * @returns The auto clear setup for the requested rendering group
  19793. */
  19794. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19795. }
  19796. }
  19797. declare module BABYLON {
  19798. /**
  19799. * This Helps creating a texture that will be created from a camera in your scene.
  19800. * It is basically a dynamic texture that could be used to create special effects for instance.
  19801. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19802. */
  19803. export class RenderTargetTexture extends Texture {
  19804. isCube: boolean;
  19805. /**
  19806. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19807. */
  19808. static readonly REFRESHRATE_RENDER_ONCE: number;
  19809. /**
  19810. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19811. */
  19812. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19813. /**
  19814. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19815. * the central point of your effect and can save a lot of performances.
  19816. */
  19817. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19818. /**
  19819. * Use this predicate to dynamically define the list of mesh you want to render.
  19820. * If set, the renderList property will be overwritten.
  19821. */
  19822. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19823. private _renderList;
  19824. /**
  19825. * Use this list to define the list of mesh you want to render.
  19826. */
  19827. renderList: Nullable<Array<AbstractMesh>>;
  19828. private _hookArray;
  19829. /**
  19830. * Define if particles should be rendered in your texture.
  19831. */
  19832. renderParticles: boolean;
  19833. /**
  19834. * Define if sprites should be rendered in your texture.
  19835. */
  19836. renderSprites: boolean;
  19837. /**
  19838. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19839. */
  19840. coordinatesMode: number;
  19841. /**
  19842. * Define the camera used to render the texture.
  19843. */
  19844. activeCamera: Nullable<Camera>;
  19845. /**
  19846. * Override the render function of the texture with your own one.
  19847. */
  19848. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19849. /**
  19850. * Define if camera post processes should be use while rendering the texture.
  19851. */
  19852. useCameraPostProcesses: boolean;
  19853. /**
  19854. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19855. */
  19856. ignoreCameraViewport: boolean;
  19857. private _postProcessManager;
  19858. private _postProcesses;
  19859. private _resizeObserver;
  19860. /**
  19861. * An event triggered when the texture is unbind.
  19862. */
  19863. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19864. /**
  19865. * An event triggered when the texture is unbind.
  19866. */
  19867. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19868. private _onAfterUnbindObserver;
  19869. /**
  19870. * Set a after unbind callback in the texture.
  19871. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19872. */
  19873. onAfterUnbind: () => void;
  19874. /**
  19875. * An event triggered before rendering the texture
  19876. */
  19877. onBeforeRenderObservable: Observable<number>;
  19878. private _onBeforeRenderObserver;
  19879. /**
  19880. * Set a before render callback in the texture.
  19881. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19882. */
  19883. onBeforeRender: (faceIndex: number) => void;
  19884. /**
  19885. * An event triggered after rendering the texture
  19886. */
  19887. onAfterRenderObservable: Observable<number>;
  19888. private _onAfterRenderObserver;
  19889. /**
  19890. * Set a after render callback in the texture.
  19891. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19892. */
  19893. onAfterRender: (faceIndex: number) => void;
  19894. /**
  19895. * An event triggered after the texture clear
  19896. */
  19897. onClearObservable: Observable<Engine>;
  19898. private _onClearObserver;
  19899. /**
  19900. * Set a clear callback in the texture.
  19901. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19902. */
  19903. onClear: (Engine: Engine) => void;
  19904. /**
  19905. * An event triggered when the texture is resized.
  19906. */
  19907. onResizeObservable: Observable<RenderTargetTexture>;
  19908. /**
  19909. * Define the clear color of the Render Target if it should be different from the scene.
  19910. */
  19911. clearColor: Color4;
  19912. protected _size: number | {
  19913. width: number;
  19914. height: number;
  19915. };
  19916. protected _initialSizeParameter: number | {
  19917. width: number;
  19918. height: number;
  19919. } | {
  19920. ratio: number;
  19921. };
  19922. protected _sizeRatio: Nullable<number>;
  19923. /** @hidden */
  19924. _generateMipMaps: boolean;
  19925. protected _renderingManager: RenderingManager;
  19926. /** @hidden */
  19927. _waitingRenderList: string[];
  19928. protected _doNotChangeAspectRatio: boolean;
  19929. protected _currentRefreshId: number;
  19930. protected _refreshRate: number;
  19931. protected _textureMatrix: Matrix;
  19932. protected _samples: number;
  19933. protected _renderTargetOptions: RenderTargetCreationOptions;
  19934. /**
  19935. * Gets render target creation options that were used.
  19936. */
  19937. readonly renderTargetOptions: RenderTargetCreationOptions;
  19938. protected _engine: Engine;
  19939. protected _onRatioRescale(): void;
  19940. /**
  19941. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19942. * It must define where the camera used to render the texture is set
  19943. */
  19944. boundingBoxPosition: Vector3;
  19945. private _boundingBoxSize;
  19946. /**
  19947. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19948. * When defined, the cubemap will switch to local mode
  19949. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19950. * @example https://www.babylonjs-playground.com/#RNASML
  19951. */
  19952. boundingBoxSize: Vector3;
  19953. /**
  19954. * In case the RTT has been created with a depth texture, get the associated
  19955. * depth texture.
  19956. * Otherwise, return null.
  19957. */
  19958. depthStencilTexture: Nullable<InternalTexture>;
  19959. /**
  19960. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19961. * or used a shadow, depth texture...
  19962. * @param name The friendly name of the texture
  19963. * @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)
  19964. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19965. * @param generateMipMaps True if mip maps need to be generated after render.
  19966. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19967. * @param type The type of the buffer in the RTT (int, half float, float...)
  19968. * @param isCube True if a cube texture needs to be created
  19969. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19970. * @param generateDepthBuffer True to generate a depth buffer
  19971. * @param generateStencilBuffer True to generate a stencil buffer
  19972. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19973. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19974. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19975. */
  19976. constructor(name: string, size: number | {
  19977. width: number;
  19978. height: number;
  19979. } | {
  19980. ratio: number;
  19981. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19982. /**
  19983. * Creates a depth stencil texture.
  19984. * This is only available in WebGL 2 or with the depth texture extension available.
  19985. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19986. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19987. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19988. */
  19989. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19990. private _processSizeParameter;
  19991. /**
  19992. * Define the number of samples to use in case of MSAA.
  19993. * It defaults to one meaning no MSAA has been enabled.
  19994. */
  19995. samples: number;
  19996. /**
  19997. * Resets the refresh counter of the texture and start bak from scratch.
  19998. * Could be useful to regenerate the texture if it is setup to render only once.
  19999. */
  20000. resetRefreshCounter(): void;
  20001. /**
  20002. * Define the refresh rate of the texture or the rendering frequency.
  20003. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20004. */
  20005. refreshRate: number;
  20006. /**
  20007. * Adds a post process to the render target rendering passes.
  20008. * @param postProcess define the post process to add
  20009. */
  20010. addPostProcess(postProcess: PostProcess): void;
  20011. /**
  20012. * Clear all the post processes attached to the render target
  20013. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20014. */
  20015. clearPostProcesses(dispose?: boolean): void;
  20016. /**
  20017. * Remove one of the post process from the list of attached post processes to the texture
  20018. * @param postProcess define the post process to remove from the list
  20019. */
  20020. removePostProcess(postProcess: PostProcess): void;
  20021. /** @hidden */
  20022. _shouldRender(): boolean;
  20023. /**
  20024. * Gets the actual render size of the texture.
  20025. * @returns the width of the render size
  20026. */
  20027. getRenderSize(): number;
  20028. /**
  20029. * Gets the actual render width of the texture.
  20030. * @returns the width of the render size
  20031. */
  20032. getRenderWidth(): number;
  20033. /**
  20034. * Gets the actual render height of the texture.
  20035. * @returns the height of the render size
  20036. */
  20037. getRenderHeight(): number;
  20038. /**
  20039. * Get if the texture can be rescaled or not.
  20040. */
  20041. readonly canRescale: boolean;
  20042. /**
  20043. * Resize the texture using a ratio.
  20044. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20045. */
  20046. scale(ratio: number): void;
  20047. /**
  20048. * Get the texture reflection matrix used to rotate/transform the reflection.
  20049. * @returns the reflection matrix
  20050. */
  20051. getReflectionTextureMatrix(): Matrix;
  20052. /**
  20053. * Resize the texture to a new desired size.
  20054. * Be carrefull as it will recreate all the data in the new texture.
  20055. * @param size Define the new size. It can be:
  20056. * - a number for squared texture,
  20057. * - an object containing { width: number, height: number }
  20058. * - or an object containing a ratio { ratio: number }
  20059. */
  20060. resize(size: number | {
  20061. width: number;
  20062. height: number;
  20063. } | {
  20064. ratio: number;
  20065. }): void;
  20066. /**
  20067. * Renders all the objects from the render list into the texture.
  20068. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20069. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20070. */
  20071. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20072. private _bestReflectionRenderTargetDimension;
  20073. /**
  20074. * @hidden
  20075. * @param faceIndex face index to bind to if this is a cubetexture
  20076. */
  20077. _bindFrameBuffer(faceIndex?: number): void;
  20078. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20079. private renderToTarget;
  20080. /**
  20081. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20082. * This allowed control for front to back rendering or reversly depending of the special needs.
  20083. *
  20084. * @param renderingGroupId The rendering group id corresponding to its index
  20085. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20086. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20087. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20088. */
  20089. 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;
  20090. /**
  20091. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20092. *
  20093. * @param renderingGroupId The rendering group id corresponding to its index
  20094. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20095. */
  20096. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20097. /**
  20098. * Clones the texture.
  20099. * @returns the cloned texture
  20100. */
  20101. clone(): RenderTargetTexture;
  20102. /**
  20103. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20104. * @returns The JSON representation of the texture
  20105. */
  20106. serialize(): any;
  20107. /**
  20108. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20109. */
  20110. disposeFramebufferObjects(): void;
  20111. /**
  20112. * Dispose the texture and release its associated resources.
  20113. */
  20114. dispose(): void;
  20115. /** @hidden */
  20116. _rebuild(): void;
  20117. /**
  20118. * Clear the info related to rendering groups preventing retention point in material dispose.
  20119. */
  20120. freeRenderingGroups(): void;
  20121. /**
  20122. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20123. * @returns the view count
  20124. */
  20125. getViewCount(): number;
  20126. }
  20127. }
  20128. declare module BABYLON {
  20129. /**
  20130. * Base class for the main features of a material in Babylon.js
  20131. */
  20132. export class Material implements IAnimatable {
  20133. /**
  20134. * Returns the triangle fill mode
  20135. */
  20136. static readonly TriangleFillMode: number;
  20137. /**
  20138. * Returns the wireframe mode
  20139. */
  20140. static readonly WireFrameFillMode: number;
  20141. /**
  20142. * Returns the point fill mode
  20143. */
  20144. static readonly PointFillMode: number;
  20145. /**
  20146. * Returns the point list draw mode
  20147. */
  20148. static readonly PointListDrawMode: number;
  20149. /**
  20150. * Returns the line list draw mode
  20151. */
  20152. static readonly LineListDrawMode: number;
  20153. /**
  20154. * Returns the line loop draw mode
  20155. */
  20156. static readonly LineLoopDrawMode: number;
  20157. /**
  20158. * Returns the line strip draw mode
  20159. */
  20160. static readonly LineStripDrawMode: number;
  20161. /**
  20162. * Returns the triangle strip draw mode
  20163. */
  20164. static readonly TriangleStripDrawMode: number;
  20165. /**
  20166. * Returns the triangle fan draw mode
  20167. */
  20168. static readonly TriangleFanDrawMode: number;
  20169. /**
  20170. * Stores the clock-wise side orientation
  20171. */
  20172. static readonly ClockWiseSideOrientation: number;
  20173. /**
  20174. * Stores the counter clock-wise side orientation
  20175. */
  20176. static readonly CounterClockWiseSideOrientation: number;
  20177. /**
  20178. * The dirty texture flag value
  20179. */
  20180. static readonly TextureDirtyFlag: number;
  20181. /**
  20182. * The dirty light flag value
  20183. */
  20184. static readonly LightDirtyFlag: number;
  20185. /**
  20186. * The dirty fresnel flag value
  20187. */
  20188. static readonly FresnelDirtyFlag: number;
  20189. /**
  20190. * The dirty attribute flag value
  20191. */
  20192. static readonly AttributesDirtyFlag: number;
  20193. /**
  20194. * The dirty misc flag value
  20195. */
  20196. static readonly MiscDirtyFlag: number;
  20197. /**
  20198. * The all dirty flag value
  20199. */
  20200. static readonly AllDirtyFlag: number;
  20201. /**
  20202. * The ID of the material
  20203. */
  20204. id: string;
  20205. /**
  20206. * Gets or sets the unique id of the material
  20207. */
  20208. uniqueId: number;
  20209. /**
  20210. * The name of the material
  20211. */
  20212. name: string;
  20213. /**
  20214. * Gets or sets user defined metadata
  20215. */
  20216. metadata: any;
  20217. /**
  20218. * For internal use only. Please do not use.
  20219. */
  20220. reservedDataStore: any;
  20221. /**
  20222. * Specifies if the ready state should be checked on each call
  20223. */
  20224. checkReadyOnEveryCall: boolean;
  20225. /**
  20226. * Specifies if the ready state should be checked once
  20227. */
  20228. checkReadyOnlyOnce: boolean;
  20229. /**
  20230. * The state of the material
  20231. */
  20232. state: string;
  20233. /**
  20234. * The alpha value of the material
  20235. */
  20236. protected _alpha: number;
  20237. /**
  20238. * List of inspectable custom properties (used by the Inspector)
  20239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20240. */
  20241. inspectableCustomProperties: IInspectable[];
  20242. /**
  20243. * Sets the alpha value of the material
  20244. */
  20245. /**
  20246. * Gets the alpha value of the material
  20247. */
  20248. alpha: number;
  20249. /**
  20250. * Specifies if back face culling is enabled
  20251. */
  20252. protected _backFaceCulling: boolean;
  20253. /**
  20254. * Sets the back-face culling state
  20255. */
  20256. /**
  20257. * Gets the back-face culling state
  20258. */
  20259. backFaceCulling: boolean;
  20260. /**
  20261. * Stores the value for side orientation
  20262. */
  20263. sideOrientation: number;
  20264. /**
  20265. * Callback triggered when the material is compiled
  20266. */
  20267. onCompiled: Nullable<(effect: Effect) => void>;
  20268. /**
  20269. * Callback triggered when an error occurs
  20270. */
  20271. onError: Nullable<(effect: Effect, errors: string) => void>;
  20272. /**
  20273. * Callback triggered to get the render target textures
  20274. */
  20275. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20276. /**
  20277. * Gets a boolean indicating that current material needs to register RTT
  20278. */
  20279. readonly hasRenderTargetTextures: boolean;
  20280. /**
  20281. * Specifies if the material should be serialized
  20282. */
  20283. doNotSerialize: boolean;
  20284. /**
  20285. * @hidden
  20286. */
  20287. _storeEffectOnSubMeshes: boolean;
  20288. /**
  20289. * Stores the animations for the material
  20290. */
  20291. animations: Nullable<Array<Animation>>;
  20292. /**
  20293. * An event triggered when the material is disposed
  20294. */
  20295. onDisposeObservable: Observable<Material>;
  20296. /**
  20297. * An observer which watches for dispose events
  20298. */
  20299. private _onDisposeObserver;
  20300. private _onUnBindObservable;
  20301. /**
  20302. * Called during a dispose event
  20303. */
  20304. onDispose: () => void;
  20305. private _onBindObservable;
  20306. /**
  20307. * An event triggered when the material is bound
  20308. */
  20309. readonly onBindObservable: Observable<AbstractMesh>;
  20310. /**
  20311. * An observer which watches for bind events
  20312. */
  20313. private _onBindObserver;
  20314. /**
  20315. * Called during a bind event
  20316. */
  20317. onBind: (Mesh: AbstractMesh) => void;
  20318. /**
  20319. * An event triggered when the material is unbound
  20320. */
  20321. readonly onUnBindObservable: Observable<Material>;
  20322. /**
  20323. * Stores the value of the alpha mode
  20324. */
  20325. private _alphaMode;
  20326. /**
  20327. * Sets the value of the alpha mode.
  20328. *
  20329. * | Value | Type | Description |
  20330. * | --- | --- | --- |
  20331. * | 0 | ALPHA_DISABLE | |
  20332. * | 1 | ALPHA_ADD | |
  20333. * | 2 | ALPHA_COMBINE | |
  20334. * | 3 | ALPHA_SUBTRACT | |
  20335. * | 4 | ALPHA_MULTIPLY | |
  20336. * | 5 | ALPHA_MAXIMIZED | |
  20337. * | 6 | ALPHA_ONEONE | |
  20338. * | 7 | ALPHA_PREMULTIPLIED | |
  20339. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20340. * | 9 | ALPHA_INTERPOLATE | |
  20341. * | 10 | ALPHA_SCREENMODE | |
  20342. *
  20343. */
  20344. /**
  20345. * Gets the value of the alpha mode
  20346. */
  20347. alphaMode: number;
  20348. /**
  20349. * Stores the state of the need depth pre-pass value
  20350. */
  20351. private _needDepthPrePass;
  20352. /**
  20353. * Sets the need depth pre-pass value
  20354. */
  20355. /**
  20356. * Gets the depth pre-pass value
  20357. */
  20358. needDepthPrePass: boolean;
  20359. /**
  20360. * Specifies if depth writing should be disabled
  20361. */
  20362. disableDepthWrite: boolean;
  20363. /**
  20364. * Specifies if depth writing should be forced
  20365. */
  20366. forceDepthWrite: boolean;
  20367. /**
  20368. * Specifies if there should be a separate pass for culling
  20369. */
  20370. separateCullingPass: boolean;
  20371. /**
  20372. * Stores the state specifing if fog should be enabled
  20373. */
  20374. private _fogEnabled;
  20375. /**
  20376. * Sets the state for enabling fog
  20377. */
  20378. /**
  20379. * Gets the value of the fog enabled state
  20380. */
  20381. fogEnabled: boolean;
  20382. /**
  20383. * Stores the size of points
  20384. */
  20385. pointSize: number;
  20386. /**
  20387. * Stores the z offset value
  20388. */
  20389. zOffset: number;
  20390. /**
  20391. * Gets a value specifying if wireframe mode is enabled
  20392. */
  20393. /**
  20394. * Sets the state of wireframe mode
  20395. */
  20396. wireframe: boolean;
  20397. /**
  20398. * Gets the value specifying if point clouds are enabled
  20399. */
  20400. /**
  20401. * Sets the state of point cloud mode
  20402. */
  20403. pointsCloud: boolean;
  20404. /**
  20405. * Gets the material fill mode
  20406. */
  20407. /**
  20408. * Sets the material fill mode
  20409. */
  20410. fillMode: number;
  20411. /**
  20412. * @hidden
  20413. * Stores the effects for the material
  20414. */
  20415. _effect: Nullable<Effect>;
  20416. /**
  20417. * @hidden
  20418. * Specifies if the material was previously ready
  20419. */
  20420. _wasPreviouslyReady: boolean;
  20421. /**
  20422. * Specifies if uniform buffers should be used
  20423. */
  20424. private _useUBO;
  20425. /**
  20426. * Stores a reference to the scene
  20427. */
  20428. private _scene;
  20429. /**
  20430. * Stores the fill mode state
  20431. */
  20432. private _fillMode;
  20433. /**
  20434. * Specifies if the depth write state should be cached
  20435. */
  20436. private _cachedDepthWriteState;
  20437. /**
  20438. * Stores the uniform buffer
  20439. */
  20440. protected _uniformBuffer: UniformBuffer;
  20441. /** @hidden */
  20442. _indexInSceneMaterialArray: number;
  20443. /** @hidden */
  20444. meshMap: Nullable<{
  20445. [id: string]: AbstractMesh | undefined;
  20446. }>;
  20447. /**
  20448. * Creates a material instance
  20449. * @param name defines the name of the material
  20450. * @param scene defines the scene to reference
  20451. * @param doNotAdd specifies if the material should be added to the scene
  20452. */
  20453. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20454. /**
  20455. * Returns a string representation of the current material
  20456. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20457. * @returns a string with material information
  20458. */
  20459. toString(fullDetails?: boolean): string;
  20460. /**
  20461. * Gets the class name of the material
  20462. * @returns a string with the class name of the material
  20463. */
  20464. getClassName(): string;
  20465. /**
  20466. * Specifies if updates for the material been locked
  20467. */
  20468. readonly isFrozen: boolean;
  20469. /**
  20470. * Locks updates for the material
  20471. */
  20472. freeze(): void;
  20473. /**
  20474. * Unlocks updates for the material
  20475. */
  20476. unfreeze(): void;
  20477. /**
  20478. * Specifies if the material is ready to be used
  20479. * @param mesh defines the mesh to check
  20480. * @param useInstances specifies if instances should be used
  20481. * @returns a boolean indicating if the material is ready to be used
  20482. */
  20483. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20484. /**
  20485. * Specifies that the submesh is ready to be used
  20486. * @param mesh defines the mesh to check
  20487. * @param subMesh defines which submesh to check
  20488. * @param useInstances specifies that instances should be used
  20489. * @returns a boolean indicating that the submesh is ready or not
  20490. */
  20491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20492. /**
  20493. * Returns the material effect
  20494. * @returns the effect associated with the material
  20495. */
  20496. getEffect(): Nullable<Effect>;
  20497. /**
  20498. * Returns the current scene
  20499. * @returns a Scene
  20500. */
  20501. getScene(): Scene;
  20502. /**
  20503. * Specifies if the material will require alpha blending
  20504. * @returns a boolean specifying if alpha blending is needed
  20505. */
  20506. needAlphaBlending(): boolean;
  20507. /**
  20508. * Specifies if the mesh will require alpha blending
  20509. * @param mesh defines the mesh to check
  20510. * @returns a boolean specifying if alpha blending is needed for the mesh
  20511. */
  20512. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20513. /**
  20514. * Specifies if this material should be rendered in alpha test mode
  20515. * @returns a boolean specifying if an alpha test is needed.
  20516. */
  20517. needAlphaTesting(): boolean;
  20518. /**
  20519. * Gets the texture used for the alpha test
  20520. * @returns the texture to use for alpha testing
  20521. */
  20522. getAlphaTestTexture(): Nullable<BaseTexture>;
  20523. /**
  20524. * Marks the material to indicate that it needs to be re-calculated
  20525. */
  20526. markDirty(): void;
  20527. /** @hidden */
  20528. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20529. /**
  20530. * Binds the material to the mesh
  20531. * @param world defines the world transformation matrix
  20532. * @param mesh defines the mesh to bind the material to
  20533. */
  20534. bind(world: Matrix, mesh?: Mesh): void;
  20535. /**
  20536. * Binds the submesh to the material
  20537. * @param world defines the world transformation matrix
  20538. * @param mesh defines the mesh containing the submesh
  20539. * @param subMesh defines the submesh to bind the material to
  20540. */
  20541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20542. /**
  20543. * Binds the world matrix to the material
  20544. * @param world defines the world transformation matrix
  20545. */
  20546. bindOnlyWorldMatrix(world: Matrix): void;
  20547. /**
  20548. * Binds the scene's uniform buffer to the effect.
  20549. * @param effect defines the effect to bind to the scene uniform buffer
  20550. * @param sceneUbo defines the uniform buffer storing scene data
  20551. */
  20552. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20553. /**
  20554. * Binds the view matrix to the effect
  20555. * @param effect defines the effect to bind the view matrix to
  20556. */
  20557. bindView(effect: Effect): void;
  20558. /**
  20559. * Binds the view projection matrix to the effect
  20560. * @param effect defines the effect to bind the view projection matrix to
  20561. */
  20562. bindViewProjection(effect: Effect): void;
  20563. /**
  20564. * Specifies if material alpha testing should be turned on for the mesh
  20565. * @param mesh defines the mesh to check
  20566. */
  20567. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20568. /**
  20569. * Processes to execute after binding the material to a mesh
  20570. * @param mesh defines the rendered mesh
  20571. */
  20572. protected _afterBind(mesh?: Mesh): void;
  20573. /**
  20574. * Unbinds the material from the mesh
  20575. */
  20576. unbind(): void;
  20577. /**
  20578. * Gets the active textures from the material
  20579. * @returns an array of textures
  20580. */
  20581. getActiveTextures(): BaseTexture[];
  20582. /**
  20583. * Specifies if the material uses a texture
  20584. * @param texture defines the texture to check against the material
  20585. * @returns a boolean specifying if the material uses the texture
  20586. */
  20587. hasTexture(texture: BaseTexture): boolean;
  20588. /**
  20589. * Makes a duplicate of the material, and gives it a new name
  20590. * @param name defines the new name for the duplicated material
  20591. * @returns the cloned material
  20592. */
  20593. clone(name: string): Nullable<Material>;
  20594. /**
  20595. * Gets the meshes bound to the material
  20596. * @returns an array of meshes bound to the material
  20597. */
  20598. getBindedMeshes(): AbstractMesh[];
  20599. /**
  20600. * Force shader compilation
  20601. * @param mesh defines the mesh associated with this material
  20602. * @param onCompiled defines a function to execute once the material is compiled
  20603. * @param options defines the options to configure the compilation
  20604. */
  20605. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20606. clipPlane: boolean;
  20607. }>): void;
  20608. /**
  20609. * Force shader compilation
  20610. * @param mesh defines the mesh that will use this material
  20611. * @param options defines additional options for compiling the shaders
  20612. * @returns a promise that resolves when the compilation completes
  20613. */
  20614. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20615. clipPlane: boolean;
  20616. }>): Promise<void>;
  20617. private static readonly _AllDirtyCallBack;
  20618. private static readonly _ImageProcessingDirtyCallBack;
  20619. private static readonly _TextureDirtyCallBack;
  20620. private static readonly _FresnelDirtyCallBack;
  20621. private static readonly _MiscDirtyCallBack;
  20622. private static readonly _LightsDirtyCallBack;
  20623. private static readonly _AttributeDirtyCallBack;
  20624. private static _FresnelAndMiscDirtyCallBack;
  20625. private static _TextureAndMiscDirtyCallBack;
  20626. private static readonly _DirtyCallbackArray;
  20627. private static readonly _RunDirtyCallBacks;
  20628. /**
  20629. * Marks a define in the material to indicate that it needs to be re-computed
  20630. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20631. */
  20632. markAsDirty(flag: number): void;
  20633. /**
  20634. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20635. * @param func defines a function which checks material defines against the submeshes
  20636. */
  20637. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20638. /**
  20639. * Indicates that we need to re-calculated for all submeshes
  20640. */
  20641. protected _markAllSubMeshesAsAllDirty(): void;
  20642. /**
  20643. * Indicates that image processing needs to be re-calculated for all submeshes
  20644. */
  20645. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20646. /**
  20647. * Indicates that textures need to be re-calculated for all submeshes
  20648. */
  20649. protected _markAllSubMeshesAsTexturesDirty(): void;
  20650. /**
  20651. * Indicates that fresnel needs to be re-calculated for all submeshes
  20652. */
  20653. protected _markAllSubMeshesAsFresnelDirty(): void;
  20654. /**
  20655. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20656. */
  20657. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20658. /**
  20659. * Indicates that lights need to be re-calculated for all submeshes
  20660. */
  20661. protected _markAllSubMeshesAsLightsDirty(): void;
  20662. /**
  20663. * Indicates that attributes need to be re-calculated for all submeshes
  20664. */
  20665. protected _markAllSubMeshesAsAttributesDirty(): void;
  20666. /**
  20667. * Indicates that misc needs to be re-calculated for all submeshes
  20668. */
  20669. protected _markAllSubMeshesAsMiscDirty(): void;
  20670. /**
  20671. * Indicates that textures and misc need to be re-calculated for all submeshes
  20672. */
  20673. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20674. /**
  20675. * Disposes the material
  20676. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20677. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20678. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20679. */
  20680. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20681. /** @hidden */
  20682. private releaseVertexArrayObject;
  20683. /**
  20684. * Serializes this material
  20685. * @returns the serialized material object
  20686. */
  20687. serialize(): any;
  20688. /**
  20689. * Creates a material from parsed material data
  20690. * @param parsedMaterial defines parsed material data
  20691. * @param scene defines the hosting scene
  20692. * @param rootUrl defines the root URL to use to load textures
  20693. * @returns a new material
  20694. */
  20695. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20696. }
  20697. }
  20698. declare module BABYLON {
  20699. /**
  20700. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20701. * separate meshes. This can be use to improve performances.
  20702. * @see http://doc.babylonjs.com/how_to/multi_materials
  20703. */
  20704. export class MultiMaterial extends Material {
  20705. private _subMaterials;
  20706. /**
  20707. * Gets or Sets the list of Materials used within the multi material.
  20708. * They need to be ordered according to the submeshes order in the associated mesh
  20709. */
  20710. subMaterials: Nullable<Material>[];
  20711. /**
  20712. * Function used to align with Node.getChildren()
  20713. * @returns the list of Materials used within the multi material
  20714. */
  20715. getChildren(): Nullable<Material>[];
  20716. /**
  20717. * Instantiates a new Multi Material
  20718. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20719. * separate meshes. This can be use to improve performances.
  20720. * @see http://doc.babylonjs.com/how_to/multi_materials
  20721. * @param name Define the name in the scene
  20722. * @param scene Define the scene the material belongs to
  20723. */
  20724. constructor(name: string, scene: Scene);
  20725. private _hookArray;
  20726. /**
  20727. * Get one of the submaterial by its index in the submaterials array
  20728. * @param index The index to look the sub material at
  20729. * @returns The Material if the index has been defined
  20730. */
  20731. getSubMaterial(index: number): Nullable<Material>;
  20732. /**
  20733. * Get the list of active textures for the whole sub materials list.
  20734. * @returns All the textures that will be used during the rendering
  20735. */
  20736. getActiveTextures(): BaseTexture[];
  20737. /**
  20738. * Gets the current class name of the material e.g. "MultiMaterial"
  20739. * Mainly use in serialization.
  20740. * @returns the class name
  20741. */
  20742. getClassName(): string;
  20743. /**
  20744. * Checks if the material is ready to render the requested sub mesh
  20745. * @param mesh Define the mesh the submesh belongs to
  20746. * @param subMesh Define the sub mesh to look readyness for
  20747. * @param useInstances Define whether or not the material is used with instances
  20748. * @returns true if ready, otherwise false
  20749. */
  20750. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20751. /**
  20752. * Clones the current material and its related sub materials
  20753. * @param name Define the name of the newly cloned material
  20754. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20755. * @returns the cloned material
  20756. */
  20757. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20758. /**
  20759. * Serializes the materials into a JSON representation.
  20760. * @returns the JSON representation
  20761. */
  20762. serialize(): any;
  20763. /**
  20764. * Dispose the material and release its associated resources
  20765. * @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)
  20766. * @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)
  20767. * @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)
  20768. */
  20769. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20770. /**
  20771. * Creates a MultiMaterial from parsed MultiMaterial data.
  20772. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20773. * @param scene defines the hosting scene
  20774. * @returns a new MultiMaterial
  20775. */
  20776. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20777. }
  20778. }
  20779. declare module BABYLON {
  20780. /**
  20781. * Base class for submeshes
  20782. */
  20783. export class BaseSubMesh {
  20784. /** @hidden */
  20785. _materialDefines: Nullable<MaterialDefines>;
  20786. /** @hidden */
  20787. _materialEffect: Nullable<Effect>;
  20788. /**
  20789. * Gets associated effect
  20790. */
  20791. readonly effect: Nullable<Effect>;
  20792. /**
  20793. * Sets associated effect (effect used to render this submesh)
  20794. * @param effect defines the effect to associate with
  20795. * @param defines defines the set of defines used to compile this effect
  20796. */
  20797. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20798. }
  20799. /**
  20800. * Defines a subdivision inside a mesh
  20801. */
  20802. export class SubMesh extends BaseSubMesh implements ICullable {
  20803. /** the material index to use */
  20804. materialIndex: number;
  20805. /** vertex index start */
  20806. verticesStart: number;
  20807. /** vertices count */
  20808. verticesCount: number;
  20809. /** index start */
  20810. indexStart: number;
  20811. /** indices count */
  20812. indexCount: number;
  20813. /** @hidden */
  20814. _linesIndexCount: number;
  20815. private _mesh;
  20816. private _renderingMesh;
  20817. private _boundingInfo;
  20818. private _linesIndexBuffer;
  20819. /** @hidden */
  20820. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20821. /** @hidden */
  20822. _trianglePlanes: Plane[];
  20823. /** @hidden */
  20824. _lastColliderTransformMatrix: Nullable<Matrix>;
  20825. /** @hidden */
  20826. _renderId: number;
  20827. /** @hidden */
  20828. _alphaIndex: number;
  20829. /** @hidden */
  20830. _distanceToCamera: number;
  20831. /** @hidden */
  20832. _id: number;
  20833. private _currentMaterial;
  20834. /**
  20835. * Add a new submesh to a mesh
  20836. * @param materialIndex defines the material index to use
  20837. * @param verticesStart defines vertex index start
  20838. * @param verticesCount defines vertices count
  20839. * @param indexStart defines index start
  20840. * @param indexCount defines indices count
  20841. * @param mesh defines the parent mesh
  20842. * @param renderingMesh defines an optional rendering mesh
  20843. * @param createBoundingBox defines if bounding box should be created for this submesh
  20844. * @returns the new submesh
  20845. */
  20846. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20847. /**
  20848. * Creates a new submesh
  20849. * @param materialIndex defines the material index to use
  20850. * @param verticesStart defines vertex index start
  20851. * @param verticesCount defines vertices count
  20852. * @param indexStart defines index start
  20853. * @param indexCount defines indices count
  20854. * @param mesh defines the parent mesh
  20855. * @param renderingMesh defines an optional rendering mesh
  20856. * @param createBoundingBox defines if bounding box should be created for this submesh
  20857. */
  20858. constructor(
  20859. /** the material index to use */
  20860. materialIndex: number,
  20861. /** vertex index start */
  20862. verticesStart: number,
  20863. /** vertices count */
  20864. verticesCount: number,
  20865. /** index start */
  20866. indexStart: number,
  20867. /** indices count */
  20868. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20869. /**
  20870. * Returns true if this submesh covers the entire parent mesh
  20871. * @ignorenaming
  20872. */
  20873. readonly IsGlobal: boolean;
  20874. /**
  20875. * Returns the submesh BoudingInfo object
  20876. * @returns current bounding info (or mesh's one if the submesh is global)
  20877. */
  20878. getBoundingInfo(): BoundingInfo;
  20879. /**
  20880. * Sets the submesh BoundingInfo
  20881. * @param boundingInfo defines the new bounding info to use
  20882. * @returns the SubMesh
  20883. */
  20884. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20885. /**
  20886. * Returns the mesh of the current submesh
  20887. * @return the parent mesh
  20888. */
  20889. getMesh(): AbstractMesh;
  20890. /**
  20891. * Returns the rendering mesh of the submesh
  20892. * @returns the rendering mesh (could be different from parent mesh)
  20893. */
  20894. getRenderingMesh(): Mesh;
  20895. /**
  20896. * Returns the submesh material
  20897. * @returns null or the current material
  20898. */
  20899. getMaterial(): Nullable<Material>;
  20900. /**
  20901. * Sets a new updated BoundingInfo object to the submesh
  20902. * @param data defines an optional position array to use to determine the bounding info
  20903. * @returns the SubMesh
  20904. */
  20905. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20906. /** @hidden */
  20907. _checkCollision(collider: Collider): boolean;
  20908. /**
  20909. * Updates the submesh BoundingInfo
  20910. * @param world defines the world matrix to use to update the bounding info
  20911. * @returns the submesh
  20912. */
  20913. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20914. /**
  20915. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20916. * @param frustumPlanes defines the frustum planes
  20917. * @returns true if the submesh is intersecting with the frustum
  20918. */
  20919. isInFrustum(frustumPlanes: Plane[]): boolean;
  20920. /**
  20921. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20922. * @param frustumPlanes defines the frustum planes
  20923. * @returns true if the submesh is inside the frustum
  20924. */
  20925. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20926. /**
  20927. * Renders the submesh
  20928. * @param enableAlphaMode defines if alpha needs to be used
  20929. * @returns the submesh
  20930. */
  20931. render(enableAlphaMode: boolean): SubMesh;
  20932. /**
  20933. * @hidden
  20934. */
  20935. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20936. /**
  20937. * Checks if the submesh intersects with a ray
  20938. * @param ray defines the ray to test
  20939. * @returns true is the passed ray intersects the submesh bounding box
  20940. */
  20941. canIntersects(ray: Ray): boolean;
  20942. /**
  20943. * Intersects current submesh with a ray
  20944. * @param ray defines the ray to test
  20945. * @param positions defines mesh's positions array
  20946. * @param indices defines mesh's indices array
  20947. * @param fastCheck defines if only bounding info should be used
  20948. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20949. * @returns intersection info or null if no intersection
  20950. */
  20951. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20952. /** @hidden */
  20953. private _intersectLines;
  20954. /** @hidden */
  20955. private _intersectUnIndexedLines;
  20956. /** @hidden */
  20957. private _intersectTriangles;
  20958. /** @hidden */
  20959. private _intersectUnIndexedTriangles;
  20960. /** @hidden */
  20961. _rebuild(): void;
  20962. /**
  20963. * Creates a new submesh from the passed mesh
  20964. * @param newMesh defines the new hosting mesh
  20965. * @param newRenderingMesh defines an optional rendering mesh
  20966. * @returns the new submesh
  20967. */
  20968. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20969. /**
  20970. * Release associated resources
  20971. */
  20972. dispose(): void;
  20973. /**
  20974. * Gets the class name
  20975. * @returns the string "SubMesh".
  20976. */
  20977. getClassName(): string;
  20978. /**
  20979. * Creates a new submesh from indices data
  20980. * @param materialIndex the index of the main mesh material
  20981. * @param startIndex the index where to start the copy in the mesh indices array
  20982. * @param indexCount the number of indices to copy then from the startIndex
  20983. * @param mesh the main mesh to create the submesh from
  20984. * @param renderingMesh the optional rendering mesh
  20985. * @returns a new submesh
  20986. */
  20987. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20988. }
  20989. }
  20990. declare module BABYLON {
  20991. /**
  20992. * Class used to represent data loading progression
  20993. */
  20994. export class SceneLoaderFlags {
  20995. private static _ForceFullSceneLoadingForIncremental;
  20996. private static _ShowLoadingScreen;
  20997. private static _CleanBoneMatrixWeights;
  20998. private static _loggingLevel;
  20999. /**
  21000. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21001. */
  21002. static ForceFullSceneLoadingForIncremental: boolean;
  21003. /**
  21004. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21005. */
  21006. static ShowLoadingScreen: boolean;
  21007. /**
  21008. * Defines the current logging level (while loading the scene)
  21009. * @ignorenaming
  21010. */
  21011. static loggingLevel: number;
  21012. /**
  21013. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21014. */
  21015. static CleanBoneMatrixWeights: boolean;
  21016. }
  21017. }
  21018. declare module BABYLON {
  21019. /**
  21020. * Class used to store geometry data (vertex buffers + index buffer)
  21021. */
  21022. export class Geometry implements IGetSetVerticesData {
  21023. /**
  21024. * Gets or sets the ID of the geometry
  21025. */
  21026. id: string;
  21027. /**
  21028. * Gets or sets the unique ID of the geometry
  21029. */
  21030. uniqueId: number;
  21031. /**
  21032. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21033. */
  21034. delayLoadState: number;
  21035. /**
  21036. * Gets the file containing the data to load when running in delay load state
  21037. */
  21038. delayLoadingFile: Nullable<string>;
  21039. /**
  21040. * Callback called when the geometry is updated
  21041. */
  21042. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21043. private _scene;
  21044. private _engine;
  21045. private _meshes;
  21046. private _totalVertices;
  21047. /** @hidden */
  21048. _indices: IndicesArray;
  21049. /** @hidden */
  21050. _vertexBuffers: {
  21051. [key: string]: VertexBuffer;
  21052. };
  21053. private _isDisposed;
  21054. private _extend;
  21055. private _boundingBias;
  21056. /** @hidden */
  21057. _delayInfo: Array<string>;
  21058. private _indexBuffer;
  21059. private _indexBufferIsUpdatable;
  21060. /** @hidden */
  21061. _boundingInfo: Nullable<BoundingInfo>;
  21062. /** @hidden */
  21063. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21064. /** @hidden */
  21065. _softwareSkinningFrameId: number;
  21066. private _vertexArrayObjects;
  21067. private _updatable;
  21068. /** @hidden */
  21069. _positions: Nullable<Vector3[]>;
  21070. /**
  21071. * 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
  21072. */
  21073. /**
  21074. * 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
  21075. */
  21076. boundingBias: Vector2;
  21077. /**
  21078. * Static function used to attach a new empty geometry to a mesh
  21079. * @param mesh defines the mesh to attach the geometry to
  21080. * @returns the new Geometry
  21081. */
  21082. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21083. /**
  21084. * Creates a new geometry
  21085. * @param id defines the unique ID
  21086. * @param scene defines the hosting scene
  21087. * @param vertexData defines the VertexData used to get geometry data
  21088. * @param updatable defines if geometry must be updatable (false by default)
  21089. * @param mesh defines the mesh that will be associated with the geometry
  21090. */
  21091. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21092. /**
  21093. * Gets the current extend of the geometry
  21094. */
  21095. readonly extend: {
  21096. minimum: Vector3;
  21097. maximum: Vector3;
  21098. };
  21099. /**
  21100. * Gets the hosting scene
  21101. * @returns the hosting Scene
  21102. */
  21103. getScene(): Scene;
  21104. /**
  21105. * Gets the hosting engine
  21106. * @returns the hosting Engine
  21107. */
  21108. getEngine(): Engine;
  21109. /**
  21110. * Defines if the geometry is ready to use
  21111. * @returns true if the geometry is ready to be used
  21112. */
  21113. isReady(): boolean;
  21114. /**
  21115. * Gets a value indicating that the geometry should not be serialized
  21116. */
  21117. readonly doNotSerialize: boolean;
  21118. /** @hidden */
  21119. _rebuild(): void;
  21120. /**
  21121. * Affects all geometry data in one call
  21122. * @param vertexData defines the geometry data
  21123. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21124. */
  21125. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21126. /**
  21127. * Set specific vertex data
  21128. * @param kind defines the data kind (Position, normal, etc...)
  21129. * @param data defines the vertex data to use
  21130. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21131. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21132. */
  21133. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21134. /**
  21135. * Removes a specific vertex data
  21136. * @param kind defines the data kind (Position, normal, etc...)
  21137. */
  21138. removeVerticesData(kind: string): void;
  21139. /**
  21140. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21141. * @param buffer defines the vertex buffer to use
  21142. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21143. */
  21144. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21145. /**
  21146. * Update a specific vertex buffer
  21147. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21148. * It will do nothing if the buffer is not updatable
  21149. * @param kind defines the data kind (Position, normal, etc...)
  21150. * @param data defines the data to use
  21151. * @param offset defines the offset in the target buffer where to store the data
  21152. * @param useBytes set to true if the offset is in bytes
  21153. */
  21154. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21155. /**
  21156. * Update a specific vertex buffer
  21157. * This function will create a new buffer if the current one is not updatable
  21158. * @param kind defines the data kind (Position, normal, etc...)
  21159. * @param data defines the data to use
  21160. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21161. */
  21162. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21163. private _updateBoundingInfo;
  21164. /** @hidden */
  21165. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21166. /**
  21167. * Gets total number of vertices
  21168. * @returns the total number of vertices
  21169. */
  21170. getTotalVertices(): number;
  21171. /**
  21172. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21173. * @param kind defines the data kind (Position, normal, etc...)
  21174. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21175. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21176. * @returns a float array containing vertex data
  21177. */
  21178. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21179. /**
  21180. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21181. * @param kind defines the data kind (Position, normal, etc...)
  21182. * @returns true if the vertex buffer with the specified kind is updatable
  21183. */
  21184. isVertexBufferUpdatable(kind: string): boolean;
  21185. /**
  21186. * Gets a specific vertex buffer
  21187. * @param kind defines the data kind (Position, normal, etc...)
  21188. * @returns a VertexBuffer
  21189. */
  21190. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21191. /**
  21192. * Returns all vertex buffers
  21193. * @return an object holding all vertex buffers indexed by kind
  21194. */
  21195. getVertexBuffers(): Nullable<{
  21196. [key: string]: VertexBuffer;
  21197. }>;
  21198. /**
  21199. * Gets a boolean indicating if specific vertex buffer is present
  21200. * @param kind defines the data kind (Position, normal, etc...)
  21201. * @returns true if data is present
  21202. */
  21203. isVerticesDataPresent(kind: string): boolean;
  21204. /**
  21205. * Gets a list of all attached data kinds (Position, normal, etc...)
  21206. * @returns a list of string containing all kinds
  21207. */
  21208. getVerticesDataKinds(): string[];
  21209. /**
  21210. * Update index buffer
  21211. * @param indices defines the indices to store in the index buffer
  21212. * @param offset defines the offset in the target buffer where to store the data
  21213. * @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)
  21214. */
  21215. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21216. /**
  21217. * Creates a new index buffer
  21218. * @param indices defines the indices to store in the index buffer
  21219. * @param totalVertices defines the total number of vertices (could be null)
  21220. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21221. */
  21222. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21223. /**
  21224. * Return the total number of indices
  21225. * @returns the total number of indices
  21226. */
  21227. getTotalIndices(): number;
  21228. /**
  21229. * Gets the index buffer array
  21230. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21231. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21232. * @returns the index buffer array
  21233. */
  21234. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21235. /**
  21236. * Gets the index buffer
  21237. * @return the index buffer
  21238. */
  21239. getIndexBuffer(): Nullable<DataBuffer>;
  21240. /** @hidden */
  21241. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21242. /**
  21243. * Release the associated resources for a specific mesh
  21244. * @param mesh defines the source mesh
  21245. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21246. */
  21247. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21248. /**
  21249. * Apply current geometry to a given mesh
  21250. * @param mesh defines the mesh to apply geometry to
  21251. */
  21252. applyToMesh(mesh: Mesh): void;
  21253. private _updateExtend;
  21254. private _applyToMesh;
  21255. private notifyUpdate;
  21256. /**
  21257. * Load the geometry if it was flagged as delay loaded
  21258. * @param scene defines the hosting scene
  21259. * @param onLoaded defines a callback called when the geometry is loaded
  21260. */
  21261. load(scene: Scene, onLoaded?: () => void): void;
  21262. private _queueLoad;
  21263. /**
  21264. * Invert the geometry to move from a right handed system to a left handed one.
  21265. */
  21266. toLeftHanded(): void;
  21267. /** @hidden */
  21268. _resetPointsArrayCache(): void;
  21269. /** @hidden */
  21270. _generatePointsArray(): boolean;
  21271. /**
  21272. * Gets a value indicating if the geometry is disposed
  21273. * @returns true if the geometry was disposed
  21274. */
  21275. isDisposed(): boolean;
  21276. private _disposeVertexArrayObjects;
  21277. /**
  21278. * Free all associated resources
  21279. */
  21280. dispose(): void;
  21281. /**
  21282. * Clone the current geometry into a new geometry
  21283. * @param id defines the unique ID of the new geometry
  21284. * @returns a new geometry object
  21285. */
  21286. copy(id: string): Geometry;
  21287. /**
  21288. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21289. * @return a JSON representation of the current geometry data (without the vertices data)
  21290. */
  21291. serialize(): any;
  21292. private toNumberArray;
  21293. /**
  21294. * Serialize all vertices data into a JSON oject
  21295. * @returns a JSON representation of the current geometry data
  21296. */
  21297. serializeVerticeData(): any;
  21298. /**
  21299. * Extracts a clone of a mesh geometry
  21300. * @param mesh defines the source mesh
  21301. * @param id defines the unique ID of the new geometry object
  21302. * @returns the new geometry object
  21303. */
  21304. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21305. /**
  21306. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21307. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21308. * Be aware Math.random() could cause collisions, but:
  21309. * "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"
  21310. * @returns a string containing a new GUID
  21311. */
  21312. static RandomId(): string;
  21313. /** @hidden */
  21314. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21315. private static _CleanMatricesWeights;
  21316. /**
  21317. * Create a new geometry from persisted data (Using .babylon file format)
  21318. * @param parsedVertexData defines the persisted data
  21319. * @param scene defines the hosting scene
  21320. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21321. * @returns the new geometry object
  21322. */
  21323. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21324. }
  21325. }
  21326. declare module BABYLON {
  21327. /**
  21328. * Define an interface for all classes that will get and set the data on vertices
  21329. */
  21330. export interface IGetSetVerticesData {
  21331. /**
  21332. * Gets a boolean indicating if specific vertex data is present
  21333. * @param kind defines the vertex data kind to use
  21334. * @returns true is data kind is present
  21335. */
  21336. isVerticesDataPresent(kind: string): boolean;
  21337. /**
  21338. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21339. * @param kind defines the data kind (Position, normal, etc...)
  21340. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21341. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21342. * @returns a float array containing vertex data
  21343. */
  21344. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21345. /**
  21346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21347. * @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.
  21348. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21349. * @returns the indices array or an empty array if the mesh has no geometry
  21350. */
  21351. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21352. /**
  21353. * Set specific vertex data
  21354. * @param kind defines the data kind (Position, normal, etc...)
  21355. * @param data defines the vertex data to use
  21356. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21357. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21358. */
  21359. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21360. /**
  21361. * Update a specific associated vertex buffer
  21362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21363. * - VertexBuffer.PositionKind
  21364. * - VertexBuffer.UVKind
  21365. * - VertexBuffer.UV2Kind
  21366. * - VertexBuffer.UV3Kind
  21367. * - VertexBuffer.UV4Kind
  21368. * - VertexBuffer.UV5Kind
  21369. * - VertexBuffer.UV6Kind
  21370. * - VertexBuffer.ColorKind
  21371. * - VertexBuffer.MatricesIndicesKind
  21372. * - VertexBuffer.MatricesIndicesExtraKind
  21373. * - VertexBuffer.MatricesWeightsKind
  21374. * - VertexBuffer.MatricesWeightsExtraKind
  21375. * @param data defines the data source
  21376. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21377. * @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)
  21378. */
  21379. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21380. /**
  21381. * Creates a new index buffer
  21382. * @param indices defines the indices to store in the index buffer
  21383. * @param totalVertices defines the total number of vertices (could be null)
  21384. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21385. */
  21386. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21387. }
  21388. /**
  21389. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21390. */
  21391. export class VertexData {
  21392. /**
  21393. * Mesh side orientation : usually the external or front surface
  21394. */
  21395. static readonly FRONTSIDE: number;
  21396. /**
  21397. * Mesh side orientation : usually the internal or back surface
  21398. */
  21399. static readonly BACKSIDE: number;
  21400. /**
  21401. * Mesh side orientation : both internal and external or front and back surfaces
  21402. */
  21403. static readonly DOUBLESIDE: number;
  21404. /**
  21405. * Mesh side orientation : by default, `FRONTSIDE`
  21406. */
  21407. static readonly DEFAULTSIDE: number;
  21408. /**
  21409. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21410. */
  21411. positions: Nullable<FloatArray>;
  21412. /**
  21413. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21414. */
  21415. normals: Nullable<FloatArray>;
  21416. /**
  21417. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21418. */
  21419. tangents: Nullable<FloatArray>;
  21420. /**
  21421. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21422. */
  21423. uvs: Nullable<FloatArray>;
  21424. /**
  21425. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21426. */
  21427. uvs2: Nullable<FloatArray>;
  21428. /**
  21429. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21430. */
  21431. uvs3: Nullable<FloatArray>;
  21432. /**
  21433. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21434. */
  21435. uvs4: Nullable<FloatArray>;
  21436. /**
  21437. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21438. */
  21439. uvs5: Nullable<FloatArray>;
  21440. /**
  21441. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21442. */
  21443. uvs6: Nullable<FloatArray>;
  21444. /**
  21445. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21446. */
  21447. colors: Nullable<FloatArray>;
  21448. /**
  21449. * 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).
  21450. */
  21451. matricesIndices: Nullable<FloatArray>;
  21452. /**
  21453. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21454. */
  21455. matricesWeights: Nullable<FloatArray>;
  21456. /**
  21457. * An array extending the number of possible indices
  21458. */
  21459. matricesIndicesExtra: Nullable<FloatArray>;
  21460. /**
  21461. * An array extending the number of possible weights when the number of indices is extended
  21462. */
  21463. matricesWeightsExtra: Nullable<FloatArray>;
  21464. /**
  21465. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21466. */
  21467. indices: Nullable<IndicesArray>;
  21468. /**
  21469. * Uses the passed data array to set the set the values for the specified kind of data
  21470. * @param data a linear array of floating numbers
  21471. * @param kind the type of data that is being set, eg positions, colors etc
  21472. */
  21473. set(data: FloatArray, kind: string): void;
  21474. /**
  21475. * Associates the vertexData to the passed Mesh.
  21476. * Sets it as updatable or not (default `false`)
  21477. * @param mesh the mesh the vertexData is applied to
  21478. * @param updatable when used and having the value true allows new data to update the vertexData
  21479. * @returns the VertexData
  21480. */
  21481. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21482. /**
  21483. * Associates the vertexData to the passed Geometry.
  21484. * Sets it as updatable or not (default `false`)
  21485. * @param geometry the geometry the vertexData is applied to
  21486. * @param updatable when used and having the value true allows new data to update the vertexData
  21487. * @returns VertexData
  21488. */
  21489. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21490. /**
  21491. * Updates the associated mesh
  21492. * @param mesh the mesh to be updated
  21493. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21494. * @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
  21495. * @returns VertexData
  21496. */
  21497. updateMesh(mesh: Mesh): VertexData;
  21498. /**
  21499. * Updates the associated geometry
  21500. * @param geometry the geometry to be updated
  21501. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21502. * @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
  21503. * @returns VertexData.
  21504. */
  21505. updateGeometry(geometry: Geometry): VertexData;
  21506. private _applyTo;
  21507. private _update;
  21508. /**
  21509. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21510. * @param matrix the transforming matrix
  21511. * @returns the VertexData
  21512. */
  21513. transform(matrix: Matrix): VertexData;
  21514. /**
  21515. * Merges the passed VertexData into the current one
  21516. * @param other the VertexData to be merged into the current one
  21517. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21518. * @returns the modified VertexData
  21519. */
  21520. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21521. private _mergeElement;
  21522. private _validate;
  21523. /**
  21524. * Serializes the VertexData
  21525. * @returns a serialized object
  21526. */
  21527. serialize(): any;
  21528. /**
  21529. * Extracts the vertexData from a mesh
  21530. * @param mesh the mesh from which to extract the VertexData
  21531. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21532. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21533. * @returns the object VertexData associated to the passed mesh
  21534. */
  21535. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21536. /**
  21537. * Extracts the vertexData from the geometry
  21538. * @param geometry the geometry from which to extract the VertexData
  21539. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21540. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21541. * @returns the object VertexData associated to the passed mesh
  21542. */
  21543. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21544. private static _ExtractFrom;
  21545. /**
  21546. * Creates the VertexData for a Ribbon
  21547. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21548. * * pathArray array of paths, each of which an array of successive Vector3
  21549. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21550. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21551. * * 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
  21552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21553. * * 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)
  21554. * * 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)
  21555. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21556. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21557. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21558. * @returns the VertexData of the ribbon
  21559. */
  21560. static CreateRibbon(options: {
  21561. pathArray: Vector3[][];
  21562. closeArray?: boolean;
  21563. closePath?: boolean;
  21564. offset?: number;
  21565. sideOrientation?: number;
  21566. frontUVs?: Vector4;
  21567. backUVs?: Vector4;
  21568. invertUV?: boolean;
  21569. uvs?: Vector2[];
  21570. colors?: Color4[];
  21571. }): VertexData;
  21572. /**
  21573. * Creates the VertexData for a box
  21574. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21575. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21576. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21577. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21578. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21579. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21580. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21582. * * 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)
  21583. * * 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)
  21584. * @returns the VertexData of the box
  21585. */
  21586. static CreateBox(options: {
  21587. size?: number;
  21588. width?: number;
  21589. height?: number;
  21590. depth?: number;
  21591. faceUV?: Vector4[];
  21592. faceColors?: Color4[];
  21593. sideOrientation?: number;
  21594. frontUVs?: Vector4;
  21595. backUVs?: Vector4;
  21596. }): VertexData;
  21597. /**
  21598. * Creates the VertexData for a tiled box
  21599. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21600. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21601. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21602. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21604. * @returns the VertexData of the box
  21605. */
  21606. static CreateTiledBox(options: {
  21607. pattern?: number;
  21608. width?: number;
  21609. height?: number;
  21610. depth?: number;
  21611. tileSize?: number;
  21612. tileWidth?: number;
  21613. tileHeight?: number;
  21614. alignHorizontal?: number;
  21615. alignVertical?: number;
  21616. faceUV?: Vector4[];
  21617. faceColors?: Color4[];
  21618. sideOrientation?: number;
  21619. }): VertexData;
  21620. /**
  21621. * Creates the VertexData for a tiled plane
  21622. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21623. * * pattern a limited pattern arrangement depending on the number
  21624. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21625. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21626. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21627. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21628. * * 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)
  21629. * * 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)
  21630. * @returns the VertexData of the tiled plane
  21631. */
  21632. static CreateTiledPlane(options: {
  21633. pattern?: number;
  21634. tileSize?: number;
  21635. tileWidth?: number;
  21636. tileHeight?: number;
  21637. size?: number;
  21638. width?: number;
  21639. height?: number;
  21640. alignHorizontal?: number;
  21641. alignVertical?: number;
  21642. sideOrientation?: number;
  21643. frontUVs?: Vector4;
  21644. backUVs?: Vector4;
  21645. }): VertexData;
  21646. /**
  21647. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21648. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21649. * * segments sets the number of horizontal strips optional, default 32
  21650. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21651. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21652. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21653. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21654. * * 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
  21655. * * 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
  21656. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21657. * * 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)
  21658. * * 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)
  21659. * @returns the VertexData of the ellipsoid
  21660. */
  21661. static CreateSphere(options: {
  21662. segments?: number;
  21663. diameter?: number;
  21664. diameterX?: number;
  21665. diameterY?: number;
  21666. diameterZ?: number;
  21667. arc?: number;
  21668. slice?: number;
  21669. sideOrientation?: number;
  21670. frontUVs?: Vector4;
  21671. backUVs?: Vector4;
  21672. }): VertexData;
  21673. /**
  21674. * Creates the VertexData for a cylinder, cone or prism
  21675. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21676. * * height sets the height (y direction) of the cylinder, optional, default 2
  21677. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21678. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21679. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21680. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21681. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21682. * * 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
  21683. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21684. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21685. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21686. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21688. * * 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)
  21689. * * 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)
  21690. * @returns the VertexData of the cylinder, cone or prism
  21691. */
  21692. static CreateCylinder(options: {
  21693. height?: number;
  21694. diameterTop?: number;
  21695. diameterBottom?: number;
  21696. diameter?: number;
  21697. tessellation?: number;
  21698. subdivisions?: number;
  21699. arc?: number;
  21700. faceColors?: Color4[];
  21701. faceUV?: Vector4[];
  21702. hasRings?: boolean;
  21703. enclose?: boolean;
  21704. sideOrientation?: number;
  21705. frontUVs?: Vector4;
  21706. backUVs?: Vector4;
  21707. }): VertexData;
  21708. /**
  21709. * Creates the VertexData for a torus
  21710. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21711. * * diameter the diameter of the torus, optional default 1
  21712. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21713. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21714. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21715. * * 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)
  21716. * * 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)
  21717. * @returns the VertexData of the torus
  21718. */
  21719. static CreateTorus(options: {
  21720. diameter?: number;
  21721. thickness?: number;
  21722. tessellation?: number;
  21723. sideOrientation?: number;
  21724. frontUVs?: Vector4;
  21725. backUVs?: Vector4;
  21726. }): VertexData;
  21727. /**
  21728. * Creates the VertexData of the LineSystem
  21729. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21730. * - lines an array of lines, each line being an array of successive Vector3
  21731. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21732. * @returns the VertexData of the LineSystem
  21733. */
  21734. static CreateLineSystem(options: {
  21735. lines: Vector3[][];
  21736. colors?: Nullable<Color4[][]>;
  21737. }): VertexData;
  21738. /**
  21739. * Create the VertexData for a DashedLines
  21740. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21741. * - points an array successive Vector3
  21742. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21743. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21744. * - dashNb the intended total number of dashes, optional, default 200
  21745. * @returns the VertexData for the DashedLines
  21746. */
  21747. static CreateDashedLines(options: {
  21748. points: Vector3[];
  21749. dashSize?: number;
  21750. gapSize?: number;
  21751. dashNb?: number;
  21752. }): VertexData;
  21753. /**
  21754. * Creates the VertexData for a Ground
  21755. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21756. * - width the width (x direction) of the ground, optional, default 1
  21757. * - height the height (z direction) of the ground, optional, default 1
  21758. * - subdivisions the number of subdivisions per side, optional, default 1
  21759. * @returns the VertexData of the Ground
  21760. */
  21761. static CreateGround(options: {
  21762. width?: number;
  21763. height?: number;
  21764. subdivisions?: number;
  21765. subdivisionsX?: number;
  21766. subdivisionsY?: number;
  21767. }): VertexData;
  21768. /**
  21769. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21770. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21771. * * xmin the ground minimum X coordinate, optional, default -1
  21772. * * zmin the ground minimum Z coordinate, optional, default -1
  21773. * * xmax the ground maximum X coordinate, optional, default 1
  21774. * * zmax the ground maximum Z coordinate, optional, default 1
  21775. * * 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}
  21776. * * 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}
  21777. * @returns the VertexData of the TiledGround
  21778. */
  21779. static CreateTiledGround(options: {
  21780. xmin: number;
  21781. zmin: number;
  21782. xmax: number;
  21783. zmax: number;
  21784. subdivisions?: {
  21785. w: number;
  21786. h: number;
  21787. };
  21788. precision?: {
  21789. w: number;
  21790. h: number;
  21791. };
  21792. }): VertexData;
  21793. /**
  21794. * Creates the VertexData of the Ground designed from a heightmap
  21795. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21796. * * width the width (x direction) of the ground
  21797. * * height the height (z direction) of the ground
  21798. * * subdivisions the number of subdivisions per side
  21799. * * minHeight the minimum altitude on the ground, optional, default 0
  21800. * * maxHeight the maximum altitude on the ground, optional default 1
  21801. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21802. * * buffer the array holding the image color data
  21803. * * bufferWidth the width of image
  21804. * * bufferHeight the height of image
  21805. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21806. * @returns the VertexData of the Ground designed from a heightmap
  21807. */
  21808. static CreateGroundFromHeightMap(options: {
  21809. width: number;
  21810. height: number;
  21811. subdivisions: number;
  21812. minHeight: number;
  21813. maxHeight: number;
  21814. colorFilter: Color3;
  21815. buffer: Uint8Array;
  21816. bufferWidth: number;
  21817. bufferHeight: number;
  21818. alphaFilter: number;
  21819. }): VertexData;
  21820. /**
  21821. * Creates the VertexData for a Plane
  21822. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21823. * * size sets the width and height of the plane to the value of size, optional default 1
  21824. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21825. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21826. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21827. * * 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)
  21828. * * 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)
  21829. * @returns the VertexData of the box
  21830. */
  21831. static CreatePlane(options: {
  21832. size?: number;
  21833. width?: number;
  21834. height?: number;
  21835. sideOrientation?: number;
  21836. frontUVs?: Vector4;
  21837. backUVs?: Vector4;
  21838. }): VertexData;
  21839. /**
  21840. * Creates the VertexData of the Disc or regular Polygon
  21841. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21842. * * radius the radius of the disc, optional default 0.5
  21843. * * tessellation the number of polygon sides, optional, default 64
  21844. * * 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
  21845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21846. * * 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)
  21847. * * 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)
  21848. * @returns the VertexData of the box
  21849. */
  21850. static CreateDisc(options: {
  21851. radius?: number;
  21852. tessellation?: number;
  21853. arc?: number;
  21854. sideOrientation?: number;
  21855. frontUVs?: Vector4;
  21856. backUVs?: Vector4;
  21857. }): VertexData;
  21858. /**
  21859. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21860. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21861. * @param polygon a mesh built from polygonTriangulation.build()
  21862. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21863. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21864. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21865. * @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)
  21866. * @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)
  21867. * @returns the VertexData of the Polygon
  21868. */
  21869. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21870. /**
  21871. * Creates the VertexData of the IcoSphere
  21872. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21873. * * radius the radius of the IcoSphere, optional default 1
  21874. * * radiusX allows stretching in the x direction, optional, default radius
  21875. * * radiusY allows stretching in the y direction, optional, default radius
  21876. * * radiusZ allows stretching in the z direction, optional, default radius
  21877. * * flat when true creates a flat shaded mesh, optional, default true
  21878. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21880. * * 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)
  21881. * * 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)
  21882. * @returns the VertexData of the IcoSphere
  21883. */
  21884. static CreateIcoSphere(options: {
  21885. radius?: number;
  21886. radiusX?: number;
  21887. radiusY?: number;
  21888. radiusZ?: number;
  21889. flat?: boolean;
  21890. subdivisions?: number;
  21891. sideOrientation?: number;
  21892. frontUVs?: Vector4;
  21893. backUVs?: Vector4;
  21894. }): VertexData;
  21895. /**
  21896. * Creates the VertexData for a Polyhedron
  21897. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21898. * * type provided types are:
  21899. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21900. * * 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)
  21901. * * size the size of the IcoSphere, optional default 1
  21902. * * sizeX allows stretching in the x direction, optional, default size
  21903. * * sizeY allows stretching in the y direction, optional, default size
  21904. * * sizeZ allows stretching in the z direction, optional, default size
  21905. * * 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
  21906. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21907. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21908. * * flat when true creates a flat shaded mesh, optional, default true
  21909. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21910. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21911. * * 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)
  21912. * * 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)
  21913. * @returns the VertexData of the Polyhedron
  21914. */
  21915. static CreatePolyhedron(options: {
  21916. type?: number;
  21917. size?: number;
  21918. sizeX?: number;
  21919. sizeY?: number;
  21920. sizeZ?: number;
  21921. custom?: any;
  21922. faceUV?: Vector4[];
  21923. faceColors?: Color4[];
  21924. flat?: boolean;
  21925. sideOrientation?: number;
  21926. frontUVs?: Vector4;
  21927. backUVs?: Vector4;
  21928. }): VertexData;
  21929. /**
  21930. * Creates the VertexData for a TorusKnot
  21931. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21932. * * radius the radius of the torus knot, optional, default 2
  21933. * * tube the thickness of the tube, optional, default 0.5
  21934. * * radialSegments the number of sides on each tube segments, optional, default 32
  21935. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21936. * * p the number of windings around the z axis, optional, default 2
  21937. * * q the number of windings around the x axis, optional, default 3
  21938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21939. * * 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)
  21940. * * 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)
  21941. * @returns the VertexData of the Torus Knot
  21942. */
  21943. static CreateTorusKnot(options: {
  21944. radius?: number;
  21945. tube?: number;
  21946. radialSegments?: number;
  21947. tubularSegments?: number;
  21948. p?: number;
  21949. q?: number;
  21950. sideOrientation?: number;
  21951. frontUVs?: Vector4;
  21952. backUVs?: Vector4;
  21953. }): VertexData;
  21954. /**
  21955. * Compute normals for given positions and indices
  21956. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21957. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21958. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21959. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21960. * * facetNormals : optional array of facet normals (vector3)
  21961. * * facetPositions : optional array of facet positions (vector3)
  21962. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21963. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21964. * * bInfo : optional bounding info, required for facetPartitioning computation
  21965. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21966. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21967. * * useRightHandedSystem: optional boolean to for right handed system computation
  21968. * * depthSort : optional boolean to enable the facet depth sort computation
  21969. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21970. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21971. */
  21972. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21973. facetNormals?: any;
  21974. facetPositions?: any;
  21975. facetPartitioning?: any;
  21976. ratio?: number;
  21977. bInfo?: any;
  21978. bbSize?: Vector3;
  21979. subDiv?: any;
  21980. useRightHandedSystem?: boolean;
  21981. depthSort?: boolean;
  21982. distanceTo?: Vector3;
  21983. depthSortedFacets?: any;
  21984. }): void;
  21985. /** @hidden */
  21986. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21987. /**
  21988. * Applies VertexData created from the imported parameters to the geometry
  21989. * @param parsedVertexData the parsed data from an imported file
  21990. * @param geometry the geometry to apply the VertexData to
  21991. */
  21992. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21993. }
  21994. }
  21995. declare module BABYLON {
  21996. /**
  21997. * Defines a target to use with MorphTargetManager
  21998. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21999. */
  22000. export class MorphTarget implements IAnimatable {
  22001. /** defines the name of the target */
  22002. name: string;
  22003. /**
  22004. * Gets or sets the list of animations
  22005. */
  22006. animations: Animation[];
  22007. private _scene;
  22008. private _positions;
  22009. private _normals;
  22010. private _tangents;
  22011. private _uvs;
  22012. private _influence;
  22013. /**
  22014. * Observable raised when the influence changes
  22015. */
  22016. onInfluenceChanged: Observable<boolean>;
  22017. /** @hidden */
  22018. _onDataLayoutChanged: Observable<void>;
  22019. /**
  22020. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22021. */
  22022. influence: number;
  22023. /**
  22024. * Gets or sets the id of the morph Target
  22025. */
  22026. id: string;
  22027. private _animationPropertiesOverride;
  22028. /**
  22029. * Gets or sets the animation properties override
  22030. */
  22031. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22032. /**
  22033. * Creates a new MorphTarget
  22034. * @param name defines the name of the target
  22035. * @param influence defines the influence to use
  22036. * @param scene defines the scene the morphtarget belongs to
  22037. */
  22038. constructor(
  22039. /** defines the name of the target */
  22040. name: string, influence?: number, scene?: Nullable<Scene>);
  22041. /**
  22042. * Gets a boolean defining if the target contains position data
  22043. */
  22044. readonly hasPositions: boolean;
  22045. /**
  22046. * Gets a boolean defining if the target contains normal data
  22047. */
  22048. readonly hasNormals: boolean;
  22049. /**
  22050. * Gets a boolean defining if the target contains tangent data
  22051. */
  22052. readonly hasTangents: boolean;
  22053. /**
  22054. * Gets a boolean defining if the target contains texture coordinates data
  22055. */
  22056. readonly hasUVs: boolean;
  22057. /**
  22058. * Affects position data to this target
  22059. * @param data defines the position data to use
  22060. */
  22061. setPositions(data: Nullable<FloatArray>): void;
  22062. /**
  22063. * Gets the position data stored in this target
  22064. * @returns a FloatArray containing the position data (or null if not present)
  22065. */
  22066. getPositions(): Nullable<FloatArray>;
  22067. /**
  22068. * Affects normal data to this target
  22069. * @param data defines the normal data to use
  22070. */
  22071. setNormals(data: Nullable<FloatArray>): void;
  22072. /**
  22073. * Gets the normal data stored in this target
  22074. * @returns a FloatArray containing the normal data (or null if not present)
  22075. */
  22076. getNormals(): Nullable<FloatArray>;
  22077. /**
  22078. * Affects tangent data to this target
  22079. * @param data defines the tangent data to use
  22080. */
  22081. setTangents(data: Nullable<FloatArray>): void;
  22082. /**
  22083. * Gets the tangent data stored in this target
  22084. * @returns a FloatArray containing the tangent data (or null if not present)
  22085. */
  22086. getTangents(): Nullable<FloatArray>;
  22087. /**
  22088. * Affects texture coordinates data to this target
  22089. * @param data defines the texture coordinates data to use
  22090. */
  22091. setUVs(data: Nullable<FloatArray>): void;
  22092. /**
  22093. * Gets the texture coordinates data stored in this target
  22094. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22095. */
  22096. getUVs(): Nullable<FloatArray>;
  22097. /**
  22098. * Serializes the current target into a Serialization object
  22099. * @returns the serialized object
  22100. */
  22101. serialize(): any;
  22102. /**
  22103. * Returns the string "MorphTarget"
  22104. * @returns "MorphTarget"
  22105. */
  22106. getClassName(): string;
  22107. /**
  22108. * Creates a new target from serialized data
  22109. * @param serializationObject defines the serialized data to use
  22110. * @returns a new MorphTarget
  22111. */
  22112. static Parse(serializationObject: any): MorphTarget;
  22113. /**
  22114. * Creates a MorphTarget from mesh data
  22115. * @param mesh defines the source mesh
  22116. * @param name defines the name to use for the new target
  22117. * @param influence defines the influence to attach to the target
  22118. * @returns a new MorphTarget
  22119. */
  22120. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22121. }
  22122. }
  22123. declare module BABYLON {
  22124. /**
  22125. * This class is used to deform meshes using morphing between different targets
  22126. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22127. */
  22128. export class MorphTargetManager {
  22129. private _targets;
  22130. private _targetInfluenceChangedObservers;
  22131. private _targetDataLayoutChangedObservers;
  22132. private _activeTargets;
  22133. private _scene;
  22134. private _influences;
  22135. private _supportsNormals;
  22136. private _supportsTangents;
  22137. private _supportsUVs;
  22138. private _vertexCount;
  22139. private _uniqueId;
  22140. private _tempInfluences;
  22141. /**
  22142. * Gets or sets a boolean indicating if normals must be morphed
  22143. */
  22144. enableNormalMorphing: boolean;
  22145. /**
  22146. * Gets or sets a boolean indicating if tangents must be morphed
  22147. */
  22148. enableTangentMorphing: boolean;
  22149. /**
  22150. * Gets or sets a boolean indicating if UV must be morphed
  22151. */
  22152. enableUVMorphing: boolean;
  22153. /**
  22154. * Creates a new MorphTargetManager
  22155. * @param scene defines the current scene
  22156. */
  22157. constructor(scene?: Nullable<Scene>);
  22158. /**
  22159. * Gets the unique ID of this manager
  22160. */
  22161. readonly uniqueId: number;
  22162. /**
  22163. * Gets the number of vertices handled by this manager
  22164. */
  22165. readonly vertexCount: number;
  22166. /**
  22167. * Gets a boolean indicating if this manager supports morphing of normals
  22168. */
  22169. readonly supportsNormals: boolean;
  22170. /**
  22171. * Gets a boolean indicating if this manager supports morphing of tangents
  22172. */
  22173. readonly supportsTangents: boolean;
  22174. /**
  22175. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22176. */
  22177. readonly supportsUVs: boolean;
  22178. /**
  22179. * Gets the number of targets stored in this manager
  22180. */
  22181. readonly numTargets: number;
  22182. /**
  22183. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22184. */
  22185. readonly numInfluencers: number;
  22186. /**
  22187. * Gets the list of influences (one per target)
  22188. */
  22189. readonly influences: Float32Array;
  22190. /**
  22191. * Gets the active target at specified index. An active target is a target with an influence > 0
  22192. * @param index defines the index to check
  22193. * @returns the requested target
  22194. */
  22195. getActiveTarget(index: number): MorphTarget;
  22196. /**
  22197. * Gets the target at specified index
  22198. * @param index defines the index to check
  22199. * @returns the requested target
  22200. */
  22201. getTarget(index: number): MorphTarget;
  22202. /**
  22203. * Add a new target to this manager
  22204. * @param target defines the target to add
  22205. */
  22206. addTarget(target: MorphTarget): void;
  22207. /**
  22208. * Removes a target from the manager
  22209. * @param target defines the target to remove
  22210. */
  22211. removeTarget(target: MorphTarget): void;
  22212. /**
  22213. * Serializes the current manager into a Serialization object
  22214. * @returns the serialized object
  22215. */
  22216. serialize(): any;
  22217. private _syncActiveTargets;
  22218. /**
  22219. * Syncrhonize the targets with all the meshes using this morph target manager
  22220. */
  22221. synchronize(): void;
  22222. /**
  22223. * Creates a new MorphTargetManager from serialized data
  22224. * @param serializationObject defines the serialized data
  22225. * @param scene defines the hosting scene
  22226. * @returns the new MorphTargetManager
  22227. */
  22228. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22229. }
  22230. }
  22231. declare module BABYLON {
  22232. /**
  22233. * Class used to represent a specific level of detail of a mesh
  22234. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22235. */
  22236. export class MeshLODLevel {
  22237. /** Defines the distance where this level should start being displayed */
  22238. distance: number;
  22239. /** Defines the mesh to use to render this level */
  22240. mesh: Nullable<Mesh>;
  22241. /**
  22242. * Creates a new LOD level
  22243. * @param distance defines the distance where this level should star being displayed
  22244. * @param mesh defines the mesh to use to render this level
  22245. */
  22246. constructor(
  22247. /** Defines the distance where this level should start being displayed */
  22248. distance: number,
  22249. /** Defines the mesh to use to render this level */
  22250. mesh: Nullable<Mesh>);
  22251. }
  22252. }
  22253. declare module BABYLON {
  22254. /**
  22255. * Mesh representing the gorund
  22256. */
  22257. export class GroundMesh extends Mesh {
  22258. /** If octree should be generated */
  22259. generateOctree: boolean;
  22260. private _heightQuads;
  22261. /** @hidden */
  22262. _subdivisionsX: number;
  22263. /** @hidden */
  22264. _subdivisionsY: number;
  22265. /** @hidden */
  22266. _width: number;
  22267. /** @hidden */
  22268. _height: number;
  22269. /** @hidden */
  22270. _minX: number;
  22271. /** @hidden */
  22272. _maxX: number;
  22273. /** @hidden */
  22274. _minZ: number;
  22275. /** @hidden */
  22276. _maxZ: number;
  22277. constructor(name: string, scene: Scene);
  22278. /**
  22279. * "GroundMesh"
  22280. * @returns "GroundMesh"
  22281. */
  22282. getClassName(): string;
  22283. /**
  22284. * The minimum of x and y subdivisions
  22285. */
  22286. readonly subdivisions: number;
  22287. /**
  22288. * X subdivisions
  22289. */
  22290. readonly subdivisionsX: number;
  22291. /**
  22292. * Y subdivisions
  22293. */
  22294. readonly subdivisionsY: number;
  22295. /**
  22296. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22297. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22298. * @param chunksCount the number of subdivisions for x and y
  22299. * @param octreeBlocksSize (Default: 32)
  22300. */
  22301. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22302. /**
  22303. * Returns a height (y) value in the Worl system :
  22304. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22305. * @param x x coordinate
  22306. * @param z z coordinate
  22307. * @returns the ground y position if (x, z) are outside the ground surface.
  22308. */
  22309. getHeightAtCoordinates(x: number, z: number): number;
  22310. /**
  22311. * Returns a normalized vector (Vector3) orthogonal to the ground
  22312. * at the ground coordinates (x, z) expressed in the World system.
  22313. * @param x x coordinate
  22314. * @param z z coordinate
  22315. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22316. */
  22317. getNormalAtCoordinates(x: number, z: number): Vector3;
  22318. /**
  22319. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22320. * at the ground coordinates (x, z) expressed in the World system.
  22321. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22322. * @param x x coordinate
  22323. * @param z z coordinate
  22324. * @param ref vector to store the result
  22325. * @returns the GroundMesh.
  22326. */
  22327. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22328. /**
  22329. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22330. * if the ground has been updated.
  22331. * This can be used in the render loop.
  22332. * @returns the GroundMesh.
  22333. */
  22334. updateCoordinateHeights(): GroundMesh;
  22335. private _getFacetAt;
  22336. private _initHeightQuads;
  22337. private _computeHeightQuads;
  22338. /**
  22339. * Serializes this ground mesh
  22340. * @param serializationObject object to write serialization to
  22341. */
  22342. serialize(serializationObject: any): void;
  22343. /**
  22344. * Parses a serialized ground mesh
  22345. * @param parsedMesh the serialized mesh
  22346. * @param scene the scene to create the ground mesh in
  22347. * @returns the created ground mesh
  22348. */
  22349. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22350. }
  22351. }
  22352. declare module BABYLON {
  22353. /**
  22354. * Interface for Physics-Joint data
  22355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22356. */
  22357. export interface PhysicsJointData {
  22358. /**
  22359. * The main pivot of the joint
  22360. */
  22361. mainPivot?: Vector3;
  22362. /**
  22363. * The connected pivot of the joint
  22364. */
  22365. connectedPivot?: Vector3;
  22366. /**
  22367. * The main axis of the joint
  22368. */
  22369. mainAxis?: Vector3;
  22370. /**
  22371. * The connected axis of the joint
  22372. */
  22373. connectedAxis?: Vector3;
  22374. /**
  22375. * The collision of the joint
  22376. */
  22377. collision?: boolean;
  22378. /**
  22379. * Native Oimo/Cannon/Energy data
  22380. */
  22381. nativeParams?: any;
  22382. }
  22383. /**
  22384. * This is a holder class for the physics joint created by the physics plugin
  22385. * It holds a set of functions to control the underlying joint
  22386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22387. */
  22388. export class PhysicsJoint {
  22389. /**
  22390. * The type of the physics joint
  22391. */
  22392. type: number;
  22393. /**
  22394. * The data for the physics joint
  22395. */
  22396. jointData: PhysicsJointData;
  22397. private _physicsJoint;
  22398. protected _physicsPlugin: IPhysicsEnginePlugin;
  22399. /**
  22400. * Initializes the physics joint
  22401. * @param type The type of the physics joint
  22402. * @param jointData The data for the physics joint
  22403. */
  22404. constructor(
  22405. /**
  22406. * The type of the physics joint
  22407. */
  22408. type: number,
  22409. /**
  22410. * The data for the physics joint
  22411. */
  22412. jointData: PhysicsJointData);
  22413. /**
  22414. * Gets the physics joint
  22415. */
  22416. /**
  22417. * Sets the physics joint
  22418. */
  22419. physicsJoint: any;
  22420. /**
  22421. * Sets the physics plugin
  22422. */
  22423. physicsPlugin: IPhysicsEnginePlugin;
  22424. /**
  22425. * Execute a function that is physics-plugin specific.
  22426. * @param {Function} func the function that will be executed.
  22427. * It accepts two parameters: the physics world and the physics joint
  22428. */
  22429. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22430. /**
  22431. * Distance-Joint type
  22432. */
  22433. static DistanceJoint: number;
  22434. /**
  22435. * Hinge-Joint type
  22436. */
  22437. static HingeJoint: number;
  22438. /**
  22439. * Ball-and-Socket joint type
  22440. */
  22441. static BallAndSocketJoint: number;
  22442. /**
  22443. * Wheel-Joint type
  22444. */
  22445. static WheelJoint: number;
  22446. /**
  22447. * Slider-Joint type
  22448. */
  22449. static SliderJoint: number;
  22450. /**
  22451. * Prismatic-Joint type
  22452. */
  22453. static PrismaticJoint: number;
  22454. /**
  22455. * Universal-Joint type
  22456. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22457. */
  22458. static UniversalJoint: number;
  22459. /**
  22460. * Hinge-Joint 2 type
  22461. */
  22462. static Hinge2Joint: number;
  22463. /**
  22464. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22465. */
  22466. static PointToPointJoint: number;
  22467. /**
  22468. * Spring-Joint type
  22469. */
  22470. static SpringJoint: number;
  22471. /**
  22472. * Lock-Joint type
  22473. */
  22474. static LockJoint: number;
  22475. }
  22476. /**
  22477. * A class representing a physics distance joint
  22478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22479. */
  22480. export class DistanceJoint extends PhysicsJoint {
  22481. /**
  22482. *
  22483. * @param jointData The data for the Distance-Joint
  22484. */
  22485. constructor(jointData: DistanceJointData);
  22486. /**
  22487. * Update the predefined distance.
  22488. * @param maxDistance The maximum preferred distance
  22489. * @param minDistance The minimum preferred distance
  22490. */
  22491. updateDistance(maxDistance: number, minDistance?: number): void;
  22492. }
  22493. /**
  22494. * Represents a Motor-Enabled Joint
  22495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22496. */
  22497. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22498. /**
  22499. * Initializes the Motor-Enabled Joint
  22500. * @param type The type of the joint
  22501. * @param jointData The physica joint data for the joint
  22502. */
  22503. constructor(type: number, jointData: PhysicsJointData);
  22504. /**
  22505. * Set the motor values.
  22506. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22507. * @param force the force to apply
  22508. * @param maxForce max force for this motor.
  22509. */
  22510. setMotor(force?: number, maxForce?: number): void;
  22511. /**
  22512. * Set the motor's limits.
  22513. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22514. * @param upperLimit The upper limit of the motor
  22515. * @param lowerLimit The lower limit of the motor
  22516. */
  22517. setLimit(upperLimit: number, lowerLimit?: number): void;
  22518. }
  22519. /**
  22520. * This class represents a single physics Hinge-Joint
  22521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22522. */
  22523. export class HingeJoint extends MotorEnabledJoint {
  22524. /**
  22525. * Initializes the Hinge-Joint
  22526. * @param jointData The joint data for the Hinge-Joint
  22527. */
  22528. constructor(jointData: PhysicsJointData);
  22529. /**
  22530. * Set the motor values.
  22531. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22532. * @param {number} force the force to apply
  22533. * @param {number} maxForce max force for this motor.
  22534. */
  22535. setMotor(force?: number, maxForce?: number): void;
  22536. /**
  22537. * Set the motor's limits.
  22538. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22539. * @param upperLimit The upper limit of the motor
  22540. * @param lowerLimit The lower limit of the motor
  22541. */
  22542. setLimit(upperLimit: number, lowerLimit?: number): void;
  22543. }
  22544. /**
  22545. * This class represents a dual hinge physics joint (same as wheel joint)
  22546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22547. */
  22548. export class Hinge2Joint extends MotorEnabledJoint {
  22549. /**
  22550. * Initializes the Hinge2-Joint
  22551. * @param jointData The joint data for the Hinge2-Joint
  22552. */
  22553. constructor(jointData: PhysicsJointData);
  22554. /**
  22555. * Set the motor values.
  22556. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22557. * @param {number} targetSpeed the speed the motor is to reach
  22558. * @param {number} maxForce max force for this motor.
  22559. * @param {motorIndex} the motor's index, 0 or 1.
  22560. */
  22561. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22562. /**
  22563. * Set the motor limits.
  22564. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22565. * @param {number} upperLimit the upper limit
  22566. * @param {number} lowerLimit lower limit
  22567. * @param {motorIndex} the motor's index, 0 or 1.
  22568. */
  22569. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22570. }
  22571. /**
  22572. * Interface for a motor enabled joint
  22573. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22574. */
  22575. export interface IMotorEnabledJoint {
  22576. /**
  22577. * Physics joint
  22578. */
  22579. physicsJoint: any;
  22580. /**
  22581. * Sets the motor of the motor-enabled joint
  22582. * @param force The force of the motor
  22583. * @param maxForce The maximum force of the motor
  22584. * @param motorIndex The index of the motor
  22585. */
  22586. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22587. /**
  22588. * Sets the limit of the motor
  22589. * @param upperLimit The upper limit of the motor
  22590. * @param lowerLimit The lower limit of the motor
  22591. * @param motorIndex The index of the motor
  22592. */
  22593. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22594. }
  22595. /**
  22596. * Joint data for a Distance-Joint
  22597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22598. */
  22599. export interface DistanceJointData extends PhysicsJointData {
  22600. /**
  22601. * Max distance the 2 joint objects can be apart
  22602. */
  22603. maxDistance: number;
  22604. }
  22605. /**
  22606. * Joint data from a spring joint
  22607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22608. */
  22609. export interface SpringJointData extends PhysicsJointData {
  22610. /**
  22611. * Length of the spring
  22612. */
  22613. length: number;
  22614. /**
  22615. * Stiffness of the spring
  22616. */
  22617. stiffness: number;
  22618. /**
  22619. * Damping of the spring
  22620. */
  22621. damping: number;
  22622. /** this callback will be called when applying the force to the impostors. */
  22623. forceApplicationCallback: () => void;
  22624. }
  22625. }
  22626. declare module BABYLON {
  22627. /**
  22628. * Holds the data for the raycast result
  22629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22630. */
  22631. export class PhysicsRaycastResult {
  22632. private _hasHit;
  22633. private _hitDistance;
  22634. private _hitNormalWorld;
  22635. private _hitPointWorld;
  22636. private _rayFromWorld;
  22637. private _rayToWorld;
  22638. /**
  22639. * Gets if there was a hit
  22640. */
  22641. readonly hasHit: boolean;
  22642. /**
  22643. * Gets the distance from the hit
  22644. */
  22645. readonly hitDistance: number;
  22646. /**
  22647. * Gets the hit normal/direction in the world
  22648. */
  22649. readonly hitNormalWorld: Vector3;
  22650. /**
  22651. * Gets the hit point in the world
  22652. */
  22653. readonly hitPointWorld: Vector3;
  22654. /**
  22655. * Gets the ray "start point" of the ray in the world
  22656. */
  22657. readonly rayFromWorld: Vector3;
  22658. /**
  22659. * Gets the ray "end point" of the ray in the world
  22660. */
  22661. readonly rayToWorld: Vector3;
  22662. /**
  22663. * Sets the hit data (normal & point in world space)
  22664. * @param hitNormalWorld defines the normal in world space
  22665. * @param hitPointWorld defines the point in world space
  22666. */
  22667. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22668. /**
  22669. * Sets the distance from the start point to the hit point
  22670. * @param distance
  22671. */
  22672. setHitDistance(distance: number): void;
  22673. /**
  22674. * Calculates the distance manually
  22675. */
  22676. calculateHitDistance(): void;
  22677. /**
  22678. * Resets all the values to default
  22679. * @param from The from point on world space
  22680. * @param to The to point on world space
  22681. */
  22682. reset(from?: Vector3, to?: Vector3): void;
  22683. }
  22684. /**
  22685. * Interface for the size containing width and height
  22686. */
  22687. interface IXYZ {
  22688. /**
  22689. * X
  22690. */
  22691. x: number;
  22692. /**
  22693. * Y
  22694. */
  22695. y: number;
  22696. /**
  22697. * Z
  22698. */
  22699. z: number;
  22700. }
  22701. }
  22702. declare module BABYLON {
  22703. /**
  22704. * Interface used to describe a physics joint
  22705. */
  22706. export interface PhysicsImpostorJoint {
  22707. /** Defines the main impostor to which the joint is linked */
  22708. mainImpostor: PhysicsImpostor;
  22709. /** Defines the impostor that is connected to the main impostor using this joint */
  22710. connectedImpostor: PhysicsImpostor;
  22711. /** Defines the joint itself */
  22712. joint: PhysicsJoint;
  22713. }
  22714. /** @hidden */
  22715. export interface IPhysicsEnginePlugin {
  22716. world: any;
  22717. name: string;
  22718. setGravity(gravity: Vector3): void;
  22719. setTimeStep(timeStep: number): void;
  22720. getTimeStep(): number;
  22721. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22722. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22724. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22725. removePhysicsBody(impostor: PhysicsImpostor): void;
  22726. generateJoint(joint: PhysicsImpostorJoint): void;
  22727. removeJoint(joint: PhysicsImpostorJoint): void;
  22728. isSupported(): boolean;
  22729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22732. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22733. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22734. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22735. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22736. getBodyMass(impostor: PhysicsImpostor): number;
  22737. getBodyFriction(impostor: PhysicsImpostor): number;
  22738. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22739. getBodyRestitution(impostor: PhysicsImpostor): number;
  22740. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22741. getBodyPressure?(impostor: PhysicsImpostor): number;
  22742. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22743. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22744. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22745. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22746. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22747. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22748. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22749. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22750. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22751. sleepBody(impostor: PhysicsImpostor): void;
  22752. wakeUpBody(impostor: PhysicsImpostor): void;
  22753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22754. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22755. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22756. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22757. getRadius(impostor: PhysicsImpostor): number;
  22758. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22759. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22760. dispose(): void;
  22761. }
  22762. /**
  22763. * Interface used to define a physics engine
  22764. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22765. */
  22766. export interface IPhysicsEngine {
  22767. /**
  22768. * Gets the gravity vector used by the simulation
  22769. */
  22770. gravity: Vector3;
  22771. /**
  22772. * Sets the gravity vector used by the simulation
  22773. * @param gravity defines the gravity vector to use
  22774. */
  22775. setGravity(gravity: Vector3): void;
  22776. /**
  22777. * Set the time step of the physics engine.
  22778. * Default is 1/60.
  22779. * To slow it down, enter 1/600 for example.
  22780. * To speed it up, 1/30
  22781. * @param newTimeStep the new timestep to apply to this world.
  22782. */
  22783. setTimeStep(newTimeStep: number): void;
  22784. /**
  22785. * Get the time step of the physics engine.
  22786. * @returns the current time step
  22787. */
  22788. getTimeStep(): number;
  22789. /**
  22790. * Release all resources
  22791. */
  22792. dispose(): void;
  22793. /**
  22794. * Gets the name of the current physics plugin
  22795. * @returns the name of the plugin
  22796. */
  22797. getPhysicsPluginName(): string;
  22798. /**
  22799. * Adding a new impostor for the impostor tracking.
  22800. * This will be done by the impostor itself.
  22801. * @param impostor the impostor to add
  22802. */
  22803. addImpostor(impostor: PhysicsImpostor): void;
  22804. /**
  22805. * Remove an impostor from the engine.
  22806. * This impostor and its mesh will not longer be updated by the physics engine.
  22807. * @param impostor the impostor to remove
  22808. */
  22809. removeImpostor(impostor: PhysicsImpostor): void;
  22810. /**
  22811. * Add a joint to the physics engine
  22812. * @param mainImpostor defines the main impostor to which the joint is added.
  22813. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22814. * @param joint defines the joint that will connect both impostors.
  22815. */
  22816. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22817. /**
  22818. * Removes a joint from the simulation
  22819. * @param mainImpostor defines the impostor used with the joint
  22820. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22821. * @param joint defines the joint to remove
  22822. */
  22823. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22824. /**
  22825. * Gets the current plugin used to run the simulation
  22826. * @returns current plugin
  22827. */
  22828. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22829. /**
  22830. * Gets the list of physic impostors
  22831. * @returns an array of PhysicsImpostor
  22832. */
  22833. getImpostors(): Array<PhysicsImpostor>;
  22834. /**
  22835. * Gets the impostor for a physics enabled object
  22836. * @param object defines the object impersonated by the impostor
  22837. * @returns the PhysicsImpostor or null if not found
  22838. */
  22839. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22840. /**
  22841. * Gets the impostor for a physics body object
  22842. * @param body defines physics body used by the impostor
  22843. * @returns the PhysicsImpostor or null if not found
  22844. */
  22845. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22846. /**
  22847. * Does a raycast in the physics world
  22848. * @param from when should the ray start?
  22849. * @param to when should the ray end?
  22850. * @returns PhysicsRaycastResult
  22851. */
  22852. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22853. /**
  22854. * Called by the scene. No need to call it.
  22855. * @param delta defines the timespam between frames
  22856. */
  22857. _step(delta: number): void;
  22858. }
  22859. }
  22860. declare module BABYLON {
  22861. /**
  22862. * The interface for the physics imposter parameters
  22863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22864. */
  22865. export interface PhysicsImpostorParameters {
  22866. /**
  22867. * The mass of the physics imposter
  22868. */
  22869. mass: number;
  22870. /**
  22871. * The friction of the physics imposter
  22872. */
  22873. friction?: number;
  22874. /**
  22875. * The coefficient of restitution of the physics imposter
  22876. */
  22877. restitution?: number;
  22878. /**
  22879. * The native options of the physics imposter
  22880. */
  22881. nativeOptions?: any;
  22882. /**
  22883. * Specifies if the parent should be ignored
  22884. */
  22885. ignoreParent?: boolean;
  22886. /**
  22887. * Specifies if bi-directional transformations should be disabled
  22888. */
  22889. disableBidirectionalTransformation?: boolean;
  22890. /**
  22891. * The pressure inside the physics imposter, soft object only
  22892. */
  22893. pressure?: number;
  22894. /**
  22895. * The stiffness the physics imposter, soft object only
  22896. */
  22897. stiffness?: number;
  22898. /**
  22899. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22900. */
  22901. velocityIterations?: number;
  22902. /**
  22903. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22904. */
  22905. positionIterations?: number;
  22906. /**
  22907. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22908. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22909. * Add to fix multiple points
  22910. */
  22911. fixedPoints?: number;
  22912. /**
  22913. * The collision margin around a soft object
  22914. */
  22915. margin?: number;
  22916. /**
  22917. * The collision margin around a soft object
  22918. */
  22919. damping?: number;
  22920. /**
  22921. * The path for a rope based on an extrusion
  22922. */
  22923. path?: any;
  22924. /**
  22925. * The shape of an extrusion used for a rope based on an extrusion
  22926. */
  22927. shape?: any;
  22928. }
  22929. /**
  22930. * Interface for a physics-enabled object
  22931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22932. */
  22933. export interface IPhysicsEnabledObject {
  22934. /**
  22935. * The position of the physics-enabled object
  22936. */
  22937. position: Vector3;
  22938. /**
  22939. * The rotation of the physics-enabled object
  22940. */
  22941. rotationQuaternion: Nullable<Quaternion>;
  22942. /**
  22943. * The scale of the physics-enabled object
  22944. */
  22945. scaling: Vector3;
  22946. /**
  22947. * The rotation of the physics-enabled object
  22948. */
  22949. rotation?: Vector3;
  22950. /**
  22951. * The parent of the physics-enabled object
  22952. */
  22953. parent?: any;
  22954. /**
  22955. * The bounding info of the physics-enabled object
  22956. * @returns The bounding info of the physics-enabled object
  22957. */
  22958. getBoundingInfo(): BoundingInfo;
  22959. /**
  22960. * Computes the world matrix
  22961. * @param force Specifies if the world matrix should be computed by force
  22962. * @returns A world matrix
  22963. */
  22964. computeWorldMatrix(force: boolean): Matrix;
  22965. /**
  22966. * Gets the world matrix
  22967. * @returns A world matrix
  22968. */
  22969. getWorldMatrix?(): Matrix;
  22970. /**
  22971. * Gets the child meshes
  22972. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22973. * @returns An array of abstract meshes
  22974. */
  22975. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22976. /**
  22977. * Gets the vertex data
  22978. * @param kind The type of vertex data
  22979. * @returns A nullable array of numbers, or a float32 array
  22980. */
  22981. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22982. /**
  22983. * Gets the indices from the mesh
  22984. * @returns A nullable array of index arrays
  22985. */
  22986. getIndices?(): Nullable<IndicesArray>;
  22987. /**
  22988. * Gets the scene from the mesh
  22989. * @returns the indices array or null
  22990. */
  22991. getScene?(): Scene;
  22992. /**
  22993. * Gets the absolute position from the mesh
  22994. * @returns the absolute position
  22995. */
  22996. getAbsolutePosition(): Vector3;
  22997. /**
  22998. * Gets the absolute pivot point from the mesh
  22999. * @returns the absolute pivot point
  23000. */
  23001. getAbsolutePivotPoint(): Vector3;
  23002. /**
  23003. * Rotates the mesh
  23004. * @param axis The axis of rotation
  23005. * @param amount The amount of rotation
  23006. * @param space The space of the rotation
  23007. * @returns The rotation transform node
  23008. */
  23009. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23010. /**
  23011. * Translates the mesh
  23012. * @param axis The axis of translation
  23013. * @param distance The distance of translation
  23014. * @param space The space of the translation
  23015. * @returns The transform node
  23016. */
  23017. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23018. /**
  23019. * Sets the absolute position of the mesh
  23020. * @param absolutePosition The absolute position of the mesh
  23021. * @returns The transform node
  23022. */
  23023. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23024. /**
  23025. * Gets the class name of the mesh
  23026. * @returns The class name
  23027. */
  23028. getClassName(): string;
  23029. }
  23030. /**
  23031. * Represents a physics imposter
  23032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23033. */
  23034. export class PhysicsImpostor {
  23035. /**
  23036. * The physics-enabled object used as the physics imposter
  23037. */
  23038. object: IPhysicsEnabledObject;
  23039. /**
  23040. * The type of the physics imposter
  23041. */
  23042. type: number;
  23043. private _options;
  23044. private _scene?;
  23045. /**
  23046. * The default object size of the imposter
  23047. */
  23048. static DEFAULT_OBJECT_SIZE: Vector3;
  23049. /**
  23050. * The identity quaternion of the imposter
  23051. */
  23052. static IDENTITY_QUATERNION: Quaternion;
  23053. /** @hidden */
  23054. _pluginData: any;
  23055. private _physicsEngine;
  23056. private _physicsBody;
  23057. private _bodyUpdateRequired;
  23058. private _onBeforePhysicsStepCallbacks;
  23059. private _onAfterPhysicsStepCallbacks;
  23060. /** @hidden */
  23061. _onPhysicsCollideCallbacks: Array<{
  23062. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23063. otherImpostors: Array<PhysicsImpostor>;
  23064. }>;
  23065. private _deltaPosition;
  23066. private _deltaRotation;
  23067. private _deltaRotationConjugated;
  23068. /** @hidden */
  23069. _isFromLine: boolean;
  23070. private _parent;
  23071. private _isDisposed;
  23072. private static _tmpVecs;
  23073. private static _tmpQuat;
  23074. /**
  23075. * Specifies if the physics imposter is disposed
  23076. */
  23077. readonly isDisposed: boolean;
  23078. /**
  23079. * Gets the mass of the physics imposter
  23080. */
  23081. mass: number;
  23082. /**
  23083. * Gets the coefficient of friction
  23084. */
  23085. /**
  23086. * Sets the coefficient of friction
  23087. */
  23088. friction: number;
  23089. /**
  23090. * Gets the coefficient of restitution
  23091. */
  23092. /**
  23093. * Sets the coefficient of restitution
  23094. */
  23095. restitution: number;
  23096. /**
  23097. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23098. */
  23099. /**
  23100. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23101. */
  23102. pressure: number;
  23103. /**
  23104. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23105. */
  23106. /**
  23107. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23108. */
  23109. stiffness: number;
  23110. /**
  23111. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23112. */
  23113. /**
  23114. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23115. */
  23116. velocityIterations: number;
  23117. /**
  23118. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23119. */
  23120. /**
  23121. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23122. */
  23123. positionIterations: number;
  23124. /**
  23125. * The unique id of the physics imposter
  23126. * set by the physics engine when adding this impostor to the array
  23127. */
  23128. uniqueId: number;
  23129. /**
  23130. * @hidden
  23131. */
  23132. soft: boolean;
  23133. /**
  23134. * @hidden
  23135. */
  23136. segments: number;
  23137. private _joints;
  23138. /**
  23139. * Initializes the physics imposter
  23140. * @param object The physics-enabled object used as the physics imposter
  23141. * @param type The type of the physics imposter
  23142. * @param _options The options for the physics imposter
  23143. * @param _scene The Babylon scene
  23144. */
  23145. constructor(
  23146. /**
  23147. * The physics-enabled object used as the physics imposter
  23148. */
  23149. object: IPhysicsEnabledObject,
  23150. /**
  23151. * The type of the physics imposter
  23152. */
  23153. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23154. /**
  23155. * This function will completly initialize this impostor.
  23156. * It will create a new body - but only if this mesh has no parent.
  23157. * If it has, this impostor will not be used other than to define the impostor
  23158. * of the child mesh.
  23159. * @hidden
  23160. */
  23161. _init(): void;
  23162. private _getPhysicsParent;
  23163. /**
  23164. * Should a new body be generated.
  23165. * @returns boolean specifying if body initialization is required
  23166. */
  23167. isBodyInitRequired(): boolean;
  23168. /**
  23169. * Sets the updated scaling
  23170. * @param updated Specifies if the scaling is updated
  23171. */
  23172. setScalingUpdated(): void;
  23173. /**
  23174. * Force a regeneration of this or the parent's impostor's body.
  23175. * Use under cautious - This will remove all joints already implemented.
  23176. */
  23177. forceUpdate(): void;
  23178. /**
  23179. * Gets the body that holds this impostor. Either its own, or its parent.
  23180. */
  23181. /**
  23182. * Set the physics body. Used mainly by the physics engine/plugin
  23183. */
  23184. physicsBody: any;
  23185. /**
  23186. * Get the parent of the physics imposter
  23187. * @returns Physics imposter or null
  23188. */
  23189. /**
  23190. * Sets the parent of the physics imposter
  23191. */
  23192. parent: Nullable<PhysicsImpostor>;
  23193. /**
  23194. * Resets the update flags
  23195. */
  23196. resetUpdateFlags(): void;
  23197. /**
  23198. * Gets the object extend size
  23199. * @returns the object extend size
  23200. */
  23201. getObjectExtendSize(): Vector3;
  23202. /**
  23203. * Gets the object center
  23204. * @returns The object center
  23205. */
  23206. getObjectCenter(): Vector3;
  23207. /**
  23208. * Get a specific parametes from the options parameter
  23209. * @param paramName The object parameter name
  23210. * @returns The object parameter
  23211. */
  23212. getParam(paramName: string): any;
  23213. /**
  23214. * Sets a specific parameter in the options given to the physics plugin
  23215. * @param paramName The parameter name
  23216. * @param value The value of the parameter
  23217. */
  23218. setParam(paramName: string, value: number): void;
  23219. /**
  23220. * Specifically change the body's mass option. Won't recreate the physics body object
  23221. * @param mass The mass of the physics imposter
  23222. */
  23223. setMass(mass: number): void;
  23224. /**
  23225. * Gets the linear velocity
  23226. * @returns linear velocity or null
  23227. */
  23228. getLinearVelocity(): Nullable<Vector3>;
  23229. /**
  23230. * Sets the linear velocity
  23231. * @param velocity linear velocity or null
  23232. */
  23233. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23234. /**
  23235. * Gets the angular velocity
  23236. * @returns angular velocity or null
  23237. */
  23238. getAngularVelocity(): Nullable<Vector3>;
  23239. /**
  23240. * Sets the angular velocity
  23241. * @param velocity The velocity or null
  23242. */
  23243. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23244. /**
  23245. * Execute a function with the physics plugin native code
  23246. * Provide a function the will have two variables - the world object and the physics body object
  23247. * @param func The function to execute with the physics plugin native code
  23248. */
  23249. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23250. /**
  23251. * Register a function that will be executed before the physics world is stepping forward
  23252. * @param func The function to execute before the physics world is stepped forward
  23253. */
  23254. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23255. /**
  23256. * Unregister a function that will be executed before the physics world is stepping forward
  23257. * @param func The function to execute before the physics world is stepped forward
  23258. */
  23259. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23260. /**
  23261. * Register a function that will be executed after the physics step
  23262. * @param func The function to execute after physics step
  23263. */
  23264. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23265. /**
  23266. * Unregisters a function that will be executed after the physics step
  23267. * @param func The function to execute after physics step
  23268. */
  23269. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23270. /**
  23271. * register a function that will be executed when this impostor collides against a different body
  23272. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23273. * @param func Callback that is executed on collision
  23274. */
  23275. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23276. /**
  23277. * Unregisters the physics imposter on contact
  23278. * @param collideAgainst The physics object to collide against
  23279. * @param func Callback to execute on collision
  23280. */
  23281. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23282. private _tmpQuat;
  23283. private _tmpQuat2;
  23284. /**
  23285. * Get the parent rotation
  23286. * @returns The parent rotation
  23287. */
  23288. getParentsRotation(): Quaternion;
  23289. /**
  23290. * this function is executed by the physics engine.
  23291. */
  23292. beforeStep: () => void;
  23293. /**
  23294. * this function is executed by the physics engine
  23295. */
  23296. afterStep: () => void;
  23297. /**
  23298. * Legacy collision detection event support
  23299. */
  23300. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23301. /**
  23302. * event and body object due to cannon's event-based architecture.
  23303. */
  23304. onCollide: (e: {
  23305. body: any;
  23306. }) => void;
  23307. /**
  23308. * Apply a force
  23309. * @param force The force to apply
  23310. * @param contactPoint The contact point for the force
  23311. * @returns The physics imposter
  23312. */
  23313. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23314. /**
  23315. * Apply an impulse
  23316. * @param force The impulse force
  23317. * @param contactPoint The contact point for the impulse force
  23318. * @returns The physics imposter
  23319. */
  23320. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23321. /**
  23322. * A help function to create a joint
  23323. * @param otherImpostor A physics imposter used to create a joint
  23324. * @param jointType The type of joint
  23325. * @param jointData The data for the joint
  23326. * @returns The physics imposter
  23327. */
  23328. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23329. /**
  23330. * Add a joint to this impostor with a different impostor
  23331. * @param otherImpostor A physics imposter used to add a joint
  23332. * @param joint The joint to add
  23333. * @returns The physics imposter
  23334. */
  23335. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23336. /**
  23337. * Add an anchor to a cloth impostor
  23338. * @param otherImpostor rigid impostor to anchor to
  23339. * @param width ratio across width from 0 to 1
  23340. * @param height ratio up height from 0 to 1
  23341. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23342. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23343. * @returns impostor the soft imposter
  23344. */
  23345. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23346. /**
  23347. * Add a hook to a rope impostor
  23348. * @param otherImpostor rigid impostor to anchor to
  23349. * @param length ratio across rope from 0 to 1
  23350. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23351. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23352. * @returns impostor the rope imposter
  23353. */
  23354. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23355. /**
  23356. * Will keep this body still, in a sleep mode.
  23357. * @returns the physics imposter
  23358. */
  23359. sleep(): PhysicsImpostor;
  23360. /**
  23361. * Wake the body up.
  23362. * @returns The physics imposter
  23363. */
  23364. wakeUp(): PhysicsImpostor;
  23365. /**
  23366. * Clones the physics imposter
  23367. * @param newObject The physics imposter clones to this physics-enabled object
  23368. * @returns A nullable physics imposter
  23369. */
  23370. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23371. /**
  23372. * Disposes the physics imposter
  23373. */
  23374. dispose(): void;
  23375. /**
  23376. * Sets the delta position
  23377. * @param position The delta position amount
  23378. */
  23379. setDeltaPosition(position: Vector3): void;
  23380. /**
  23381. * Sets the delta rotation
  23382. * @param rotation The delta rotation amount
  23383. */
  23384. setDeltaRotation(rotation: Quaternion): void;
  23385. /**
  23386. * Gets the box size of the physics imposter and stores the result in the input parameter
  23387. * @param result Stores the box size
  23388. * @returns The physics imposter
  23389. */
  23390. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23391. /**
  23392. * Gets the radius of the physics imposter
  23393. * @returns Radius of the physics imposter
  23394. */
  23395. getRadius(): number;
  23396. /**
  23397. * Sync a bone with this impostor
  23398. * @param bone The bone to sync to the impostor.
  23399. * @param boneMesh The mesh that the bone is influencing.
  23400. * @param jointPivot The pivot of the joint / bone in local space.
  23401. * @param distToJoint Optional distance from the impostor to the joint.
  23402. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23403. */
  23404. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23405. /**
  23406. * Sync impostor to a bone
  23407. * @param bone The bone that the impostor will be synced to.
  23408. * @param boneMesh The mesh that the bone is influencing.
  23409. * @param jointPivot The pivot of the joint / bone in local space.
  23410. * @param distToJoint Optional distance from the impostor to the joint.
  23411. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23412. * @param boneAxis Optional vector3 axis the bone is aligned with
  23413. */
  23414. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23415. /**
  23416. * No-Imposter type
  23417. */
  23418. static NoImpostor: number;
  23419. /**
  23420. * Sphere-Imposter type
  23421. */
  23422. static SphereImpostor: number;
  23423. /**
  23424. * Box-Imposter type
  23425. */
  23426. static BoxImpostor: number;
  23427. /**
  23428. * Plane-Imposter type
  23429. */
  23430. static PlaneImpostor: number;
  23431. /**
  23432. * Mesh-imposter type
  23433. */
  23434. static MeshImpostor: number;
  23435. /**
  23436. * Capsule-Impostor type (Ammo.js plugin only)
  23437. */
  23438. static CapsuleImpostor: number;
  23439. /**
  23440. * Cylinder-Imposter type
  23441. */
  23442. static CylinderImpostor: number;
  23443. /**
  23444. * Particle-Imposter type
  23445. */
  23446. static ParticleImpostor: number;
  23447. /**
  23448. * Heightmap-Imposter type
  23449. */
  23450. static HeightmapImpostor: number;
  23451. /**
  23452. * ConvexHull-Impostor type (Ammo.js plugin only)
  23453. */
  23454. static ConvexHullImpostor: number;
  23455. /**
  23456. * Rope-Imposter type
  23457. */
  23458. static RopeImpostor: number;
  23459. /**
  23460. * Cloth-Imposter type
  23461. */
  23462. static ClothImpostor: number;
  23463. /**
  23464. * Softbody-Imposter type
  23465. */
  23466. static SoftbodyImpostor: number;
  23467. }
  23468. }
  23469. declare module BABYLON {
  23470. /**
  23471. * @hidden
  23472. **/
  23473. export class _CreationDataStorage {
  23474. closePath?: boolean;
  23475. closeArray?: boolean;
  23476. idx: number[];
  23477. dashSize: number;
  23478. gapSize: number;
  23479. path3D: Path3D;
  23480. pathArray: Vector3[][];
  23481. arc: number;
  23482. radius: number;
  23483. cap: number;
  23484. tessellation: number;
  23485. }
  23486. /**
  23487. * @hidden
  23488. **/
  23489. class _InstanceDataStorage {
  23490. visibleInstances: any;
  23491. batchCache: _InstancesBatch;
  23492. instancesBufferSize: number;
  23493. instancesBuffer: Nullable<Buffer>;
  23494. instancesData: Float32Array;
  23495. overridenInstanceCount: number;
  23496. isFrozen: boolean;
  23497. previousBatch: Nullable<_InstancesBatch>;
  23498. hardwareInstancedRendering: boolean;
  23499. sideOrientation: number;
  23500. }
  23501. /**
  23502. * @hidden
  23503. **/
  23504. export class _InstancesBatch {
  23505. mustReturn: boolean;
  23506. visibleInstances: Nullable<InstancedMesh[]>[];
  23507. renderSelf: boolean[];
  23508. hardwareInstancedRendering: boolean[];
  23509. }
  23510. /**
  23511. * Class used to represent renderable models
  23512. */
  23513. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23514. /**
  23515. * Mesh side orientation : usually the external or front surface
  23516. */
  23517. static readonly FRONTSIDE: number;
  23518. /**
  23519. * Mesh side orientation : usually the internal or back surface
  23520. */
  23521. static readonly BACKSIDE: number;
  23522. /**
  23523. * Mesh side orientation : both internal and external or front and back surfaces
  23524. */
  23525. static readonly DOUBLESIDE: number;
  23526. /**
  23527. * Mesh side orientation : by default, `FRONTSIDE`
  23528. */
  23529. static readonly DEFAULTSIDE: number;
  23530. /**
  23531. * Mesh cap setting : no cap
  23532. */
  23533. static readonly NO_CAP: number;
  23534. /**
  23535. * Mesh cap setting : one cap at the beginning of the mesh
  23536. */
  23537. static readonly CAP_START: number;
  23538. /**
  23539. * Mesh cap setting : one cap at the end of the mesh
  23540. */
  23541. static readonly CAP_END: number;
  23542. /**
  23543. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23544. */
  23545. static readonly CAP_ALL: number;
  23546. /**
  23547. * Mesh pattern setting : no flip or rotate
  23548. */
  23549. static readonly NO_FLIP: number;
  23550. /**
  23551. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23552. */
  23553. static readonly FLIP_TILE: number;
  23554. /**
  23555. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23556. */
  23557. static readonly ROTATE_TILE: number;
  23558. /**
  23559. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23560. */
  23561. static readonly FLIP_ROW: number;
  23562. /**
  23563. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23564. */
  23565. static readonly ROTATE_ROW: number;
  23566. /**
  23567. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23568. */
  23569. static readonly FLIP_N_ROTATE_TILE: number;
  23570. /**
  23571. * Mesh pattern setting : rotate pattern and rotate
  23572. */
  23573. static readonly FLIP_N_ROTATE_ROW: number;
  23574. /**
  23575. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23576. */
  23577. static readonly CENTER: number;
  23578. /**
  23579. * Mesh tile positioning : part tiles on left
  23580. */
  23581. static readonly LEFT: number;
  23582. /**
  23583. * Mesh tile positioning : part tiles on right
  23584. */
  23585. static readonly RIGHT: number;
  23586. /**
  23587. * Mesh tile positioning : part tiles on top
  23588. */
  23589. static readonly TOP: number;
  23590. /**
  23591. * Mesh tile positioning : part tiles on bottom
  23592. */
  23593. static readonly BOTTOM: number;
  23594. /**
  23595. * Gets the default side orientation.
  23596. * @param orientation the orientation to value to attempt to get
  23597. * @returns the default orientation
  23598. * @hidden
  23599. */
  23600. static _GetDefaultSideOrientation(orientation?: number): number;
  23601. private _internalMeshDataInfo;
  23602. /**
  23603. * An event triggered before rendering the mesh
  23604. */
  23605. readonly onBeforeRenderObservable: Observable<Mesh>;
  23606. /**
  23607. * An event triggered before binding the mesh
  23608. */
  23609. readonly onBeforeBindObservable: Observable<Mesh>;
  23610. /**
  23611. * An event triggered after rendering the mesh
  23612. */
  23613. readonly onAfterRenderObservable: Observable<Mesh>;
  23614. /**
  23615. * An event triggered before drawing the mesh
  23616. */
  23617. readonly onBeforeDrawObservable: Observable<Mesh>;
  23618. private _onBeforeDrawObserver;
  23619. /**
  23620. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23621. */
  23622. onBeforeDraw: () => void;
  23623. readonly hasInstances: boolean;
  23624. /**
  23625. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23626. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23627. */
  23628. delayLoadState: number;
  23629. /**
  23630. * Gets the list of instances created from this mesh
  23631. * it is not supposed to be modified manually.
  23632. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23633. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23634. */
  23635. instances: InstancedMesh[];
  23636. /**
  23637. * Gets the file containing delay loading data for this mesh
  23638. */
  23639. delayLoadingFile: string;
  23640. /** @hidden */
  23641. _binaryInfo: any;
  23642. /**
  23643. * User defined function used to change how LOD level selection is done
  23644. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23645. */
  23646. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23647. /**
  23648. * Gets or sets the morph target manager
  23649. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23650. */
  23651. morphTargetManager: Nullable<MorphTargetManager>;
  23652. /** @hidden */
  23653. _creationDataStorage: Nullable<_CreationDataStorage>;
  23654. /** @hidden */
  23655. _geometry: Nullable<Geometry>;
  23656. /** @hidden */
  23657. _delayInfo: Array<string>;
  23658. /** @hidden */
  23659. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23660. /** @hidden */
  23661. _instanceDataStorage: _InstanceDataStorage;
  23662. private _effectiveMaterial;
  23663. /** @hidden */
  23664. _shouldGenerateFlatShading: boolean;
  23665. /** @hidden */
  23666. _originalBuilderSideOrientation: number;
  23667. /**
  23668. * Use this property to change the original side orientation defined at construction time
  23669. */
  23670. overrideMaterialSideOrientation: Nullable<number>;
  23671. /**
  23672. * Gets the source mesh (the one used to clone this one from)
  23673. */
  23674. readonly source: Nullable<Mesh>;
  23675. /**
  23676. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23677. */
  23678. isUnIndexed: boolean;
  23679. /**
  23680. * @constructor
  23681. * @param name The value used by scene.getMeshByName() to do a lookup.
  23682. * @param scene The scene to add this mesh to.
  23683. * @param parent The parent of this mesh, if it has one
  23684. * @param source An optional Mesh from which geometry is shared, cloned.
  23685. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23686. * When false, achieved by calling a clone(), also passing False.
  23687. * This will make creation of children, recursive.
  23688. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23689. */
  23690. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23691. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23692. /**
  23693. * Gets the class name
  23694. * @returns the string "Mesh".
  23695. */
  23696. getClassName(): string;
  23697. /** @hidden */
  23698. readonly _isMesh: boolean;
  23699. /**
  23700. * Returns a description of this mesh
  23701. * @param fullDetails define if full details about this mesh must be used
  23702. * @returns a descriptive string representing this mesh
  23703. */
  23704. toString(fullDetails?: boolean): string;
  23705. /** @hidden */
  23706. _unBindEffect(): void;
  23707. /**
  23708. * Gets a boolean indicating if this mesh has LOD
  23709. */
  23710. readonly hasLODLevels: boolean;
  23711. /**
  23712. * Gets the list of MeshLODLevel associated with the current mesh
  23713. * @returns an array of MeshLODLevel
  23714. */
  23715. getLODLevels(): MeshLODLevel[];
  23716. private _sortLODLevels;
  23717. /**
  23718. * Add a mesh as LOD level triggered at the given distance.
  23719. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23720. * @param distance The distance from the center of the object to show this level
  23721. * @param mesh The mesh to be added as LOD level (can be null)
  23722. * @return This mesh (for chaining)
  23723. */
  23724. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23725. /**
  23726. * Returns the LOD level mesh at the passed distance or null if not found.
  23727. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23728. * @param distance The distance from the center of the object to show this level
  23729. * @returns a Mesh or `null`
  23730. */
  23731. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23732. /**
  23733. * Remove a mesh from the LOD array
  23734. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23735. * @param mesh defines the mesh to be removed
  23736. * @return This mesh (for chaining)
  23737. */
  23738. removeLODLevel(mesh: Mesh): Mesh;
  23739. /**
  23740. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23741. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23742. * @param camera defines the camera to use to compute distance
  23743. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23744. * @return This mesh (for chaining)
  23745. */
  23746. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23747. /**
  23748. * Gets the mesh internal Geometry object
  23749. */
  23750. readonly geometry: Nullable<Geometry>;
  23751. /**
  23752. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23753. * @returns the total number of vertices
  23754. */
  23755. getTotalVertices(): number;
  23756. /**
  23757. * Returns the content of an associated vertex buffer
  23758. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23759. * - VertexBuffer.PositionKind
  23760. * - VertexBuffer.UVKind
  23761. * - VertexBuffer.UV2Kind
  23762. * - VertexBuffer.UV3Kind
  23763. * - VertexBuffer.UV4Kind
  23764. * - VertexBuffer.UV5Kind
  23765. * - VertexBuffer.UV6Kind
  23766. * - VertexBuffer.ColorKind
  23767. * - VertexBuffer.MatricesIndicesKind
  23768. * - VertexBuffer.MatricesIndicesExtraKind
  23769. * - VertexBuffer.MatricesWeightsKind
  23770. * - VertexBuffer.MatricesWeightsExtraKind
  23771. * @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
  23772. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23773. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23774. */
  23775. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23776. /**
  23777. * Returns the mesh VertexBuffer object from the requested `kind`
  23778. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23779. * - VertexBuffer.PositionKind
  23780. * - VertexBuffer.NormalKind
  23781. * - VertexBuffer.UVKind
  23782. * - VertexBuffer.UV2Kind
  23783. * - VertexBuffer.UV3Kind
  23784. * - VertexBuffer.UV4Kind
  23785. * - VertexBuffer.UV5Kind
  23786. * - VertexBuffer.UV6Kind
  23787. * - VertexBuffer.ColorKind
  23788. * - VertexBuffer.MatricesIndicesKind
  23789. * - VertexBuffer.MatricesIndicesExtraKind
  23790. * - VertexBuffer.MatricesWeightsKind
  23791. * - VertexBuffer.MatricesWeightsExtraKind
  23792. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23793. */
  23794. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23795. /**
  23796. * Tests if a specific vertex buffer is associated with this mesh
  23797. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23798. * - VertexBuffer.PositionKind
  23799. * - VertexBuffer.NormalKind
  23800. * - VertexBuffer.UVKind
  23801. * - VertexBuffer.UV2Kind
  23802. * - VertexBuffer.UV3Kind
  23803. * - VertexBuffer.UV4Kind
  23804. * - VertexBuffer.UV5Kind
  23805. * - VertexBuffer.UV6Kind
  23806. * - VertexBuffer.ColorKind
  23807. * - VertexBuffer.MatricesIndicesKind
  23808. * - VertexBuffer.MatricesIndicesExtraKind
  23809. * - VertexBuffer.MatricesWeightsKind
  23810. * - VertexBuffer.MatricesWeightsExtraKind
  23811. * @returns a boolean
  23812. */
  23813. isVerticesDataPresent(kind: string): boolean;
  23814. /**
  23815. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23816. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23817. * - VertexBuffer.PositionKind
  23818. * - VertexBuffer.UVKind
  23819. * - VertexBuffer.UV2Kind
  23820. * - VertexBuffer.UV3Kind
  23821. * - VertexBuffer.UV4Kind
  23822. * - VertexBuffer.UV5Kind
  23823. * - VertexBuffer.UV6Kind
  23824. * - VertexBuffer.ColorKind
  23825. * - VertexBuffer.MatricesIndicesKind
  23826. * - VertexBuffer.MatricesIndicesExtraKind
  23827. * - VertexBuffer.MatricesWeightsKind
  23828. * - VertexBuffer.MatricesWeightsExtraKind
  23829. * @returns a boolean
  23830. */
  23831. isVertexBufferUpdatable(kind: string): boolean;
  23832. /**
  23833. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23834. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23835. * - VertexBuffer.PositionKind
  23836. * - VertexBuffer.NormalKind
  23837. * - VertexBuffer.UVKind
  23838. * - VertexBuffer.UV2Kind
  23839. * - VertexBuffer.UV3Kind
  23840. * - VertexBuffer.UV4Kind
  23841. * - VertexBuffer.UV5Kind
  23842. * - VertexBuffer.UV6Kind
  23843. * - VertexBuffer.ColorKind
  23844. * - VertexBuffer.MatricesIndicesKind
  23845. * - VertexBuffer.MatricesIndicesExtraKind
  23846. * - VertexBuffer.MatricesWeightsKind
  23847. * - VertexBuffer.MatricesWeightsExtraKind
  23848. * @returns an array of strings
  23849. */
  23850. getVerticesDataKinds(): string[];
  23851. /**
  23852. * Returns a positive integer : the total number of indices in this mesh geometry.
  23853. * @returns the numner of indices or zero if the mesh has no geometry.
  23854. */
  23855. getTotalIndices(): number;
  23856. /**
  23857. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23858. * @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.
  23859. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23860. * @returns the indices array or an empty array if the mesh has no geometry
  23861. */
  23862. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23863. readonly isBlocked: boolean;
  23864. /**
  23865. * Determine if the current mesh is ready to be rendered
  23866. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23867. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23868. * @returns true if all associated assets are ready (material, textures, shaders)
  23869. */
  23870. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23871. /**
  23872. * 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.
  23873. */
  23874. readonly areNormalsFrozen: boolean;
  23875. /**
  23876. * 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.
  23877. * @returns the current mesh
  23878. */
  23879. freezeNormals(): Mesh;
  23880. /**
  23881. * 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
  23882. * @returns the current mesh
  23883. */
  23884. unfreezeNormals(): Mesh;
  23885. /**
  23886. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23887. */
  23888. overridenInstanceCount: number;
  23889. /** @hidden */
  23890. _preActivate(): Mesh;
  23891. /** @hidden */
  23892. _preActivateForIntermediateRendering(renderId: number): Mesh;
  23893. /** @hidden */
  23894. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23895. /**
  23896. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23897. * This means the mesh underlying bounding box and sphere are recomputed.
  23898. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23899. * @returns the current mesh
  23900. */
  23901. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23902. /** @hidden */
  23903. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23904. /**
  23905. * This function will subdivide the mesh into multiple submeshes
  23906. * @param count defines the expected number of submeshes
  23907. */
  23908. subdivide(count: number): void;
  23909. /**
  23910. * Copy a FloatArray into a specific associated vertex buffer
  23911. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23912. * - VertexBuffer.PositionKind
  23913. * - VertexBuffer.UVKind
  23914. * - VertexBuffer.UV2Kind
  23915. * - VertexBuffer.UV3Kind
  23916. * - VertexBuffer.UV4Kind
  23917. * - VertexBuffer.UV5Kind
  23918. * - VertexBuffer.UV6Kind
  23919. * - VertexBuffer.ColorKind
  23920. * - VertexBuffer.MatricesIndicesKind
  23921. * - VertexBuffer.MatricesIndicesExtraKind
  23922. * - VertexBuffer.MatricesWeightsKind
  23923. * - VertexBuffer.MatricesWeightsExtraKind
  23924. * @param data defines the data source
  23925. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23926. * @param stride defines the data stride size (can be null)
  23927. * @returns the current mesh
  23928. */
  23929. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23930. /**
  23931. * Flags an associated vertex buffer as updatable
  23932. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23933. * - VertexBuffer.PositionKind
  23934. * - VertexBuffer.UVKind
  23935. * - VertexBuffer.UV2Kind
  23936. * - VertexBuffer.UV3Kind
  23937. * - VertexBuffer.UV4Kind
  23938. * - VertexBuffer.UV5Kind
  23939. * - VertexBuffer.UV6Kind
  23940. * - VertexBuffer.ColorKind
  23941. * - VertexBuffer.MatricesIndicesKind
  23942. * - VertexBuffer.MatricesIndicesExtraKind
  23943. * - VertexBuffer.MatricesWeightsKind
  23944. * - VertexBuffer.MatricesWeightsExtraKind
  23945. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23946. */
  23947. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23948. /**
  23949. * Sets the mesh global Vertex Buffer
  23950. * @param buffer defines the buffer to use
  23951. * @returns the current mesh
  23952. */
  23953. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23954. /**
  23955. * Update a specific associated vertex buffer
  23956. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23957. * - VertexBuffer.PositionKind
  23958. * - VertexBuffer.UVKind
  23959. * - VertexBuffer.UV2Kind
  23960. * - VertexBuffer.UV3Kind
  23961. * - VertexBuffer.UV4Kind
  23962. * - VertexBuffer.UV5Kind
  23963. * - VertexBuffer.UV6Kind
  23964. * - VertexBuffer.ColorKind
  23965. * - VertexBuffer.MatricesIndicesKind
  23966. * - VertexBuffer.MatricesIndicesExtraKind
  23967. * - VertexBuffer.MatricesWeightsKind
  23968. * - VertexBuffer.MatricesWeightsExtraKind
  23969. * @param data defines the data source
  23970. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23971. * @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)
  23972. * @returns the current mesh
  23973. */
  23974. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23975. /**
  23976. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23977. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23978. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23979. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23980. * @returns the current mesh
  23981. */
  23982. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23983. /**
  23984. * Creates a un-shared specific occurence of the geometry for the mesh.
  23985. * @returns the current mesh
  23986. */
  23987. makeGeometryUnique(): Mesh;
  23988. /**
  23989. * Set the index buffer of this mesh
  23990. * @param indices defines the source data
  23991. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23992. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23993. * @returns the current mesh
  23994. */
  23995. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23996. /**
  23997. * Update the current index buffer
  23998. * @param indices defines the source data
  23999. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24000. * @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)
  24001. * @returns the current mesh
  24002. */
  24003. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24004. /**
  24005. * Invert the geometry to move from a right handed system to a left handed one.
  24006. * @returns the current mesh
  24007. */
  24008. toLeftHanded(): Mesh;
  24009. /** @hidden */
  24010. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24011. /** @hidden */
  24012. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24013. /**
  24014. * Registers for this mesh a javascript function called just before the rendering process
  24015. * @param func defines the function to call before rendering this mesh
  24016. * @returns the current mesh
  24017. */
  24018. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24019. /**
  24020. * Disposes a previously registered javascript function called before the rendering
  24021. * @param func defines the function to remove
  24022. * @returns the current mesh
  24023. */
  24024. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24025. /**
  24026. * Registers for this mesh a javascript function called just after the rendering is complete
  24027. * @param func defines the function to call after rendering this mesh
  24028. * @returns the current mesh
  24029. */
  24030. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24031. /**
  24032. * Disposes a previously registered javascript function called after the rendering.
  24033. * @param func defines the function to remove
  24034. * @returns the current mesh
  24035. */
  24036. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24037. /** @hidden */
  24038. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24039. /** @hidden */
  24040. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24041. /** @hidden */
  24042. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24043. /** @hidden */
  24044. _rebuild(): void;
  24045. /** @hidden */
  24046. _freeze(): void;
  24047. /** @hidden */
  24048. _unFreeze(): void;
  24049. /**
  24050. * 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
  24051. * @param subMesh defines the subMesh to render
  24052. * @param enableAlphaMode defines if alpha mode can be changed
  24053. * @returns the current mesh
  24054. */
  24055. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24056. private _onBeforeDraw;
  24057. /**
  24058. * Renormalize the mesh and patch it up if there are no weights
  24059. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24060. * However in the case of zero weights then we set just a single influence to 1.
  24061. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24062. */
  24063. cleanMatrixWeights(): void;
  24064. private normalizeSkinFourWeights;
  24065. private normalizeSkinWeightsAndExtra;
  24066. /**
  24067. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24068. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24069. * the user know there was an issue with importing the mesh
  24070. * @returns a validation object with skinned, valid and report string
  24071. */
  24072. validateSkinning(): {
  24073. skinned: boolean;
  24074. valid: boolean;
  24075. report: string;
  24076. };
  24077. /** @hidden */
  24078. _checkDelayState(): Mesh;
  24079. private _queueLoad;
  24080. /**
  24081. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24082. * A mesh is in the frustum if its bounding box intersects the frustum
  24083. * @param frustumPlanes defines the frustum to test
  24084. * @returns true if the mesh is in the frustum planes
  24085. */
  24086. isInFrustum(frustumPlanes: Plane[]): boolean;
  24087. /**
  24088. * Sets the mesh material by the material or multiMaterial `id` property
  24089. * @param id is a string identifying the material or the multiMaterial
  24090. * @returns the current mesh
  24091. */
  24092. setMaterialByID(id: string): Mesh;
  24093. /**
  24094. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24095. * @returns an array of IAnimatable
  24096. */
  24097. getAnimatables(): IAnimatable[];
  24098. /**
  24099. * Modifies the mesh geometry according to the passed transformation matrix.
  24100. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24101. * The mesh normals are modified using the same transformation.
  24102. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24103. * @param transform defines the transform matrix to use
  24104. * @see http://doc.babylonjs.com/resources/baking_transformations
  24105. * @returns the current mesh
  24106. */
  24107. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24108. /**
  24109. * Modifies the mesh geometry according to its own current World Matrix.
  24110. * The mesh World Matrix is then reset.
  24111. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24112. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24113. * @see http://doc.babylonjs.com/resources/baking_transformations
  24114. * @returns the current mesh
  24115. */
  24116. bakeCurrentTransformIntoVertices(): Mesh;
  24117. /** @hidden */
  24118. readonly _positions: Nullable<Vector3[]>;
  24119. /** @hidden */
  24120. _resetPointsArrayCache(): Mesh;
  24121. /** @hidden */
  24122. _generatePointsArray(): boolean;
  24123. /**
  24124. * Returns a new Mesh object generated from the current mesh properties.
  24125. * This method must not get confused with createInstance()
  24126. * @param name is a string, the name given to the new mesh
  24127. * @param newParent can be any Node object (default `null`)
  24128. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24129. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24130. * @returns a new mesh
  24131. */
  24132. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24133. /**
  24134. * Releases resources associated with this mesh.
  24135. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24136. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24137. */
  24138. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24139. /**
  24140. * Modifies the mesh geometry according to a displacement map.
  24141. * 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.
  24142. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24143. * @param url is a string, the URL from the image file is to be downloaded.
  24144. * @param minHeight is the lower limit of the displacement.
  24145. * @param maxHeight is the upper limit of the displacement.
  24146. * @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.
  24147. * @param uvOffset is an optional vector2 used to offset UV.
  24148. * @param uvScale is an optional vector2 used to scale UV.
  24149. * @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.
  24150. * @returns the Mesh.
  24151. */
  24152. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24153. /**
  24154. * Modifies the mesh geometry according to a displacementMap buffer.
  24155. * 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.
  24156. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24157. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24158. * @param heightMapWidth is the width of the buffer image.
  24159. * @param heightMapHeight is the height of the buffer image.
  24160. * @param minHeight is the lower limit of the displacement.
  24161. * @param maxHeight is the upper limit of the displacement.
  24162. * @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.
  24163. * @param uvOffset is an optional vector2 used to offset UV.
  24164. * @param uvScale is an optional vector2 used to scale UV.
  24165. * @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.
  24166. * @returns the Mesh.
  24167. */
  24168. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24169. /**
  24170. * Modify the mesh to get a flat shading rendering.
  24171. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24172. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24173. * @returns current mesh
  24174. */
  24175. convertToFlatShadedMesh(): Mesh;
  24176. /**
  24177. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24178. * In other words, more vertices, no more indices and a single bigger VBO.
  24179. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24180. * @returns current mesh
  24181. */
  24182. convertToUnIndexedMesh(): Mesh;
  24183. /**
  24184. * Inverses facet orientations.
  24185. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24186. * @param flipNormals will also inverts the normals
  24187. * @returns current mesh
  24188. */
  24189. flipFaces(flipNormals?: boolean): Mesh;
  24190. /**
  24191. * Increase the number of facets and hence vertices in a mesh
  24192. * Vertex normals are interpolated from existing vertex normals
  24193. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24194. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24195. */
  24196. increaseVertices(numberPerEdge: number): void;
  24197. /**
  24198. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24199. * This will undo any application of covertToFlatShadedMesh
  24200. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24201. */
  24202. forceSharedVertices(): void;
  24203. /** @hidden */
  24204. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24205. /** @hidden */
  24206. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24207. /**
  24208. * Creates a new InstancedMesh object from the mesh model.
  24209. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24210. * @param name defines the name of the new instance
  24211. * @returns a new InstancedMesh
  24212. */
  24213. createInstance(name: string): InstancedMesh;
  24214. /**
  24215. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24216. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24217. * @returns the current mesh
  24218. */
  24219. synchronizeInstances(): Mesh;
  24220. /**
  24221. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24222. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24223. * This should be used together with the simplification to avoid disappearing triangles.
  24224. * @param successCallback an optional success callback to be called after the optimization finished.
  24225. * @returns the current mesh
  24226. */
  24227. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24228. /**
  24229. * Serialize current mesh
  24230. * @param serializationObject defines the object which will receive the serialization data
  24231. */
  24232. serialize(serializationObject: any): void;
  24233. /** @hidden */
  24234. _syncGeometryWithMorphTargetManager(): void;
  24235. /** @hidden */
  24236. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24237. /**
  24238. * Returns a new Mesh object parsed from the source provided.
  24239. * @param parsedMesh is the source
  24240. * @param scene defines the hosting scene
  24241. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24242. * @returns a new Mesh
  24243. */
  24244. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24245. /**
  24246. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24247. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24248. * @param name defines the name of the mesh to create
  24249. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24250. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24251. * @param closePath creates a seam between the first and the last points of each path of the path array
  24252. * @param offset is taken in account only if the `pathArray` is containing a single path
  24253. * @param scene defines the hosting scene
  24254. * @param updatable defines if the mesh must be flagged as updatable
  24255. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24256. * @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)
  24257. * @returns a new Mesh
  24258. */
  24259. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24260. /**
  24261. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24262. * @param name defines the name of the mesh to create
  24263. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24264. * @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
  24265. * @param scene defines the hosting scene
  24266. * @param updatable defines if the mesh must be flagged as updatable
  24267. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24268. * @returns a new Mesh
  24269. */
  24270. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24271. /**
  24272. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24273. * @param name defines the name of the mesh to create
  24274. * @param size sets the size (float) of each box side (default 1)
  24275. * @param scene defines the hosting scene
  24276. * @param updatable defines if the mesh must be flagged as updatable
  24277. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24278. * @returns a new Mesh
  24279. */
  24280. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24281. /**
  24282. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24283. * @param name defines the name of the mesh to create
  24284. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24285. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24286. * @param scene defines the hosting scene
  24287. * @param updatable defines if the mesh must be flagged as updatable
  24288. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24289. * @returns a new Mesh
  24290. */
  24291. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24292. /**
  24293. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24294. * @param name defines the name of the mesh to create
  24295. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24296. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24297. * @param scene defines the hosting scene
  24298. * @returns a new Mesh
  24299. */
  24300. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24301. /**
  24302. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24303. * @param name defines the name of the mesh to create
  24304. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24305. * @param diameterTop set the top cap diameter (floats, default 1)
  24306. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24307. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24308. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24309. * @param scene defines the hosting scene
  24310. * @param updatable defines if the mesh must be flagged as updatable
  24311. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24312. * @returns a new Mesh
  24313. */
  24314. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24315. /**
  24316. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24317. * @param name defines the name of the mesh to create
  24318. * @param diameter sets the diameter size (float) of the torus (default 1)
  24319. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24320. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24321. * @param scene defines the hosting scene
  24322. * @param updatable defines if the mesh must be flagged as updatable
  24323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24324. * @returns a new Mesh
  24325. */
  24326. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24327. /**
  24328. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24329. * @param name defines the name of the mesh to create
  24330. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24331. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24332. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24333. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24334. * @param p the number of windings on X axis (positive integers, default 2)
  24335. * @param q the number of windings on Y axis (positive integers, default 3)
  24336. * @param scene defines the hosting scene
  24337. * @param updatable defines if the mesh must be flagged as updatable
  24338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24339. * @returns a new Mesh
  24340. */
  24341. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24342. /**
  24343. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24344. * @param name defines the name of the mesh to create
  24345. * @param points is an array successive Vector3
  24346. * @param scene defines the hosting scene
  24347. * @param updatable defines if the mesh must be flagged as updatable
  24348. * @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).
  24349. * @returns a new Mesh
  24350. */
  24351. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24352. /**
  24353. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24354. * @param name defines the name of the mesh to create
  24355. * @param points is an array successive Vector3
  24356. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24357. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24358. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24359. * @param scene defines the hosting scene
  24360. * @param updatable defines if the mesh must be flagged as updatable
  24361. * @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)
  24362. * @returns a new Mesh
  24363. */
  24364. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24365. /**
  24366. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24367. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24368. * 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.
  24369. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24370. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24371. * Remember you can only change the shape positions, not their number when updating a polygon.
  24372. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24373. * @param name defines the name of the mesh to create
  24374. * @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
  24375. * @param scene defines the hosting scene
  24376. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24377. * @param updatable defines if the mesh must be flagged as updatable
  24378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24379. * @param earcutInjection can be used to inject your own earcut reference
  24380. * @returns a new Mesh
  24381. */
  24382. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24383. /**
  24384. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24385. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24386. * @param name defines the name of the mesh to create
  24387. * @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
  24388. * @param depth defines the height of extrusion
  24389. * @param scene defines the hosting scene
  24390. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24391. * @param updatable defines if the mesh must be flagged as updatable
  24392. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24393. * @param earcutInjection can be used to inject your own earcut reference
  24394. * @returns a new Mesh
  24395. */
  24396. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24397. /**
  24398. * Creates an extruded shape mesh.
  24399. * 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
  24400. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24401. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24402. * @param name defines the name of the mesh to create
  24403. * @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
  24404. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24405. * @param scale is the value to scale the shape
  24406. * @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
  24407. * @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
  24408. * @param scene defines the hosting scene
  24409. * @param updatable defines if the mesh must be flagged as updatable
  24410. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24411. * @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)
  24412. * @returns a new Mesh
  24413. */
  24414. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24415. /**
  24416. * Creates an custom extruded shape mesh.
  24417. * The custom extrusion is a parametric shape.
  24418. * It has no predefined shape. Its final shape will depend on the input parameters.
  24419. * Please consider using the same method from the MeshBuilder class instead
  24420. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24421. * @param name defines the name of the mesh to create
  24422. * @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
  24423. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24424. * @param scaleFunction is a custom Javascript function called on each path point
  24425. * @param rotationFunction is a custom Javascript function called on each path point
  24426. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24427. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24428. * @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
  24429. * @param scene defines the hosting scene
  24430. * @param updatable defines if the mesh must be flagged as updatable
  24431. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24432. * @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)
  24433. * @returns a new Mesh
  24434. */
  24435. 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;
  24436. /**
  24437. * Creates lathe mesh.
  24438. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24439. * Please consider using the same method from the MeshBuilder class instead
  24440. * @param name defines the name of the mesh to create
  24441. * @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
  24442. * @param radius is the radius value of the lathe
  24443. * @param tessellation is the side number of the lathe.
  24444. * @param scene defines the hosting scene
  24445. * @param updatable defines if the mesh must be flagged as updatable
  24446. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24447. * @returns a new Mesh
  24448. */
  24449. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24450. /**
  24451. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24452. * @param name defines the name of the mesh to create
  24453. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24454. * @param scene defines the hosting scene
  24455. * @param updatable defines if the mesh must be flagged as updatable
  24456. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24457. * @returns a new Mesh
  24458. */
  24459. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24460. /**
  24461. * Creates a ground mesh.
  24462. * Please consider using the same method from the MeshBuilder class instead
  24463. * @param name defines the name of the mesh to create
  24464. * @param width set the width of the ground
  24465. * @param height set the height of the ground
  24466. * @param subdivisions sets the number of subdivisions per side
  24467. * @param scene defines the hosting scene
  24468. * @param updatable defines if the mesh must be flagged as updatable
  24469. * @returns a new Mesh
  24470. */
  24471. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24472. /**
  24473. * Creates a tiled ground mesh.
  24474. * Please consider using the same method from the MeshBuilder class instead
  24475. * @param name defines the name of the mesh to create
  24476. * @param xmin set the ground minimum X coordinate
  24477. * @param zmin set the ground minimum Y coordinate
  24478. * @param xmax set the ground maximum X coordinate
  24479. * @param zmax set the ground maximum Z coordinate
  24480. * @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
  24481. * @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
  24482. * @param scene defines the hosting scene
  24483. * @param updatable defines if the mesh must be flagged as updatable
  24484. * @returns a new Mesh
  24485. */
  24486. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24487. w: number;
  24488. h: number;
  24489. }, precision: {
  24490. w: number;
  24491. h: number;
  24492. }, scene: Scene, updatable?: boolean): Mesh;
  24493. /**
  24494. * Creates a ground mesh from a height map.
  24495. * Please consider using the same method from the MeshBuilder class instead
  24496. * @see http://doc.babylonjs.com/babylon101/height_map
  24497. * @param name defines the name of the mesh to create
  24498. * @param url sets the URL of the height map image resource
  24499. * @param width set the ground width size
  24500. * @param height set the ground height size
  24501. * @param subdivisions sets the number of subdivision per side
  24502. * @param minHeight is the minimum altitude on the ground
  24503. * @param maxHeight is the maximum altitude on the ground
  24504. * @param scene defines the hosting scene
  24505. * @param updatable defines if the mesh must be flagged as updatable
  24506. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24507. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24508. * @returns a new Mesh
  24509. */
  24510. 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;
  24511. /**
  24512. * Creates a tube mesh.
  24513. * The tube is a parametric shape.
  24514. * It has no predefined shape. Its final shape will depend on the input parameters.
  24515. * Please consider using the same method from the MeshBuilder class instead
  24516. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24517. * @param name defines the name of the mesh to create
  24518. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24519. * @param radius sets the tube radius size
  24520. * @param tessellation is the number of sides on the tubular surface
  24521. * @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
  24522. * @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
  24523. * @param scene defines the hosting scene
  24524. * @param updatable defines if the mesh must be flagged as updatable
  24525. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24526. * @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)
  24527. * @returns a new Mesh
  24528. */
  24529. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24530. (i: number, distance: number): number;
  24531. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24532. /**
  24533. * Creates a polyhedron mesh.
  24534. * Please consider using the same method from the MeshBuilder class instead.
  24535. * * 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
  24536. * * The parameter `size` (positive float, default 1) sets the polygon size
  24537. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24538. * * 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`
  24539. * * 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
  24540. * * 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)`)
  24541. * * 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
  24542. * * 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
  24543. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24544. * * 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
  24545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24546. * @param name defines the name of the mesh to create
  24547. * @param options defines the options used to create the mesh
  24548. * @param scene defines the hosting scene
  24549. * @returns a new Mesh
  24550. */
  24551. static CreatePolyhedron(name: string, options: {
  24552. type?: number;
  24553. size?: number;
  24554. sizeX?: number;
  24555. sizeY?: number;
  24556. sizeZ?: number;
  24557. custom?: any;
  24558. faceUV?: Vector4[];
  24559. faceColors?: Color4[];
  24560. updatable?: boolean;
  24561. sideOrientation?: number;
  24562. }, scene: Scene): Mesh;
  24563. /**
  24564. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24565. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24566. * * 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`)
  24567. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24568. * * 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
  24569. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24570. * * 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
  24571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24572. * @param name defines the name of the mesh
  24573. * @param options defines the options used to create the mesh
  24574. * @param scene defines the hosting scene
  24575. * @returns a new Mesh
  24576. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24577. */
  24578. static CreateIcoSphere(name: string, options: {
  24579. radius?: number;
  24580. flat?: boolean;
  24581. subdivisions?: number;
  24582. sideOrientation?: number;
  24583. updatable?: boolean;
  24584. }, scene: Scene): Mesh;
  24585. /**
  24586. * Creates a decal mesh.
  24587. * Please consider using the same method from the MeshBuilder class instead.
  24588. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24589. * @param name defines the name of the mesh
  24590. * @param sourceMesh defines the mesh receiving the decal
  24591. * @param position sets the position of the decal in world coordinates
  24592. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24593. * @param size sets the decal scaling
  24594. * @param angle sets the angle to rotate the decal
  24595. * @returns a new Mesh
  24596. */
  24597. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24598. /**
  24599. * Prepare internal position array for software CPU skinning
  24600. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24601. */
  24602. setPositionsForCPUSkinning(): Float32Array;
  24603. /**
  24604. * Prepare internal normal array for software CPU skinning
  24605. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24606. */
  24607. setNormalsForCPUSkinning(): Float32Array;
  24608. /**
  24609. * Updates the vertex buffer by applying transformation from the bones
  24610. * @param skeleton defines the skeleton to apply to current mesh
  24611. * @returns the current mesh
  24612. */
  24613. applySkeleton(skeleton: Skeleton): Mesh;
  24614. /**
  24615. * 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
  24616. * @param meshes defines the list of meshes to scan
  24617. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24618. */
  24619. static MinMax(meshes: AbstractMesh[]): {
  24620. min: Vector3;
  24621. max: Vector3;
  24622. };
  24623. /**
  24624. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24625. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24626. * @returns a vector3
  24627. */
  24628. static Center(meshesOrMinMaxVector: {
  24629. min: Vector3;
  24630. max: Vector3;
  24631. } | AbstractMesh[]): Vector3;
  24632. /**
  24633. * Merge the array of meshes into a single mesh for performance reasons.
  24634. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24635. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24636. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24637. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24638. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24639. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24640. * @returns a new mesh
  24641. */
  24642. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24643. /** @hidden */
  24644. addInstance(instance: InstancedMesh): void;
  24645. /** @hidden */
  24646. removeInstance(instance: InstancedMesh): void;
  24647. }
  24648. }
  24649. declare module BABYLON {
  24650. /**
  24651. * This is the base class of all the camera used in the application.
  24652. * @see http://doc.babylonjs.com/features/cameras
  24653. */
  24654. export class Camera extends Node {
  24655. /** @hidden */
  24656. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24657. /**
  24658. * This is the default projection mode used by the cameras.
  24659. * It helps recreating a feeling of perspective and better appreciate depth.
  24660. * This is the best way to simulate real life cameras.
  24661. */
  24662. static readonly PERSPECTIVE_CAMERA: number;
  24663. /**
  24664. * This helps creating camera with an orthographic mode.
  24665. * 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.
  24666. */
  24667. static readonly ORTHOGRAPHIC_CAMERA: number;
  24668. /**
  24669. * This is the default FOV mode for perspective cameras.
  24670. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24671. */
  24672. static readonly FOVMODE_VERTICAL_FIXED: number;
  24673. /**
  24674. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24675. */
  24676. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24677. /**
  24678. * This specifies ther is no need for a camera rig.
  24679. * Basically only one eye is rendered corresponding to the camera.
  24680. */
  24681. static readonly RIG_MODE_NONE: number;
  24682. /**
  24683. * Simulates a camera Rig with one blue eye and one red eye.
  24684. * This can be use with 3d blue and red glasses.
  24685. */
  24686. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24687. /**
  24688. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24689. */
  24690. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24691. /**
  24692. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24693. */
  24694. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24695. /**
  24696. * Defines that both eyes of the camera will be rendered over under each other.
  24697. */
  24698. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24699. /**
  24700. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24701. */
  24702. static readonly RIG_MODE_VR: number;
  24703. /**
  24704. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24705. */
  24706. static readonly RIG_MODE_WEBVR: number;
  24707. /**
  24708. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24709. */
  24710. static readonly RIG_MODE_CUSTOM: number;
  24711. /**
  24712. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24713. */
  24714. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24715. /**
  24716. * Define the input manager associated with the camera.
  24717. */
  24718. inputs: CameraInputsManager<Camera>;
  24719. /** @hidden */
  24720. _position: Vector3;
  24721. /**
  24722. * Define the current local position of the camera in the scene
  24723. */
  24724. position: Vector3;
  24725. /**
  24726. * The vector the camera should consider as up.
  24727. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24728. */
  24729. upVector: Vector3;
  24730. /**
  24731. * Define the current limit on the left side for an orthographic camera
  24732. * In scene unit
  24733. */
  24734. orthoLeft: Nullable<number>;
  24735. /**
  24736. * Define the current limit on the right side for an orthographic camera
  24737. * In scene unit
  24738. */
  24739. orthoRight: Nullable<number>;
  24740. /**
  24741. * Define the current limit on the bottom side for an orthographic camera
  24742. * In scene unit
  24743. */
  24744. orthoBottom: Nullable<number>;
  24745. /**
  24746. * Define the current limit on the top side for an orthographic camera
  24747. * In scene unit
  24748. */
  24749. orthoTop: Nullable<number>;
  24750. /**
  24751. * Field Of View is set in Radians. (default is 0.8)
  24752. */
  24753. fov: number;
  24754. /**
  24755. * Define the minimum distance the camera can see from.
  24756. * This is important to note that the depth buffer are not infinite and the closer it starts
  24757. * the more your scene might encounter depth fighting issue.
  24758. */
  24759. minZ: number;
  24760. /**
  24761. * Define the maximum distance the camera can see to.
  24762. * This is important to note that the depth buffer are not infinite and the further it end
  24763. * the more your scene might encounter depth fighting issue.
  24764. */
  24765. maxZ: number;
  24766. /**
  24767. * Define the default inertia of the camera.
  24768. * This helps giving a smooth feeling to the camera movement.
  24769. */
  24770. inertia: number;
  24771. /**
  24772. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24773. */
  24774. mode: number;
  24775. /**
  24776. * Define wether the camera is intermediate.
  24777. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24778. */
  24779. isIntermediate: boolean;
  24780. /**
  24781. * Define the viewport of the camera.
  24782. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24783. */
  24784. viewport: Viewport;
  24785. /**
  24786. * Restricts the camera to viewing objects with the same layerMask.
  24787. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24788. */
  24789. layerMask: number;
  24790. /**
  24791. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24792. */
  24793. fovMode: number;
  24794. /**
  24795. * Rig mode of the camera.
  24796. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24797. * This is normally controlled byt the camera themselves as internal use.
  24798. */
  24799. cameraRigMode: number;
  24800. /**
  24801. * Defines the distance between both "eyes" in case of a RIG
  24802. */
  24803. interaxialDistance: number;
  24804. /**
  24805. * Defines if stereoscopic rendering is done side by side or over under.
  24806. */
  24807. isStereoscopicSideBySide: boolean;
  24808. /**
  24809. * 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
  24810. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24811. * else in the scene. (Eg. security camera)
  24812. *
  24813. * 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)
  24814. */
  24815. customRenderTargets: RenderTargetTexture[];
  24816. /**
  24817. * When set, the camera will render to this render target instead of the default canvas
  24818. *
  24819. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24820. */
  24821. outputRenderTarget: Nullable<RenderTargetTexture>;
  24822. /**
  24823. * Observable triggered when the camera view matrix has changed.
  24824. */
  24825. onViewMatrixChangedObservable: Observable<Camera>;
  24826. /**
  24827. * Observable triggered when the camera Projection matrix has changed.
  24828. */
  24829. onProjectionMatrixChangedObservable: Observable<Camera>;
  24830. /**
  24831. * Observable triggered when the inputs have been processed.
  24832. */
  24833. onAfterCheckInputsObservable: Observable<Camera>;
  24834. /**
  24835. * Observable triggered when reset has been called and applied to the camera.
  24836. */
  24837. onRestoreStateObservable: Observable<Camera>;
  24838. /** @hidden */
  24839. _cameraRigParams: any;
  24840. /** @hidden */
  24841. _rigCameras: Camera[];
  24842. /** @hidden */
  24843. _rigPostProcess: Nullable<PostProcess>;
  24844. protected _webvrViewMatrix: Matrix;
  24845. /** @hidden */
  24846. _skipRendering: boolean;
  24847. /** @hidden */
  24848. _projectionMatrix: Matrix;
  24849. /** @hidden */
  24850. _postProcesses: Nullable<PostProcess>[];
  24851. /** @hidden */
  24852. _activeMeshes: SmartArray<AbstractMesh>;
  24853. protected _globalPosition: Vector3;
  24854. /** @hidden */
  24855. _computedViewMatrix: Matrix;
  24856. private _doNotComputeProjectionMatrix;
  24857. private _transformMatrix;
  24858. private _frustumPlanes;
  24859. private _refreshFrustumPlanes;
  24860. private _storedFov;
  24861. private _stateStored;
  24862. /**
  24863. * Instantiates a new camera object.
  24864. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24865. * @see http://doc.babylonjs.com/features/cameras
  24866. * @param name Defines the name of the camera in the scene
  24867. * @param position Defines the position of the camera
  24868. * @param scene Defines the scene the camera belongs too
  24869. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24870. */
  24871. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24872. /**
  24873. * Store current camera state (fov, position, etc..)
  24874. * @returns the camera
  24875. */
  24876. storeState(): Camera;
  24877. /**
  24878. * Restores the camera state values if it has been stored. You must call storeState() first
  24879. */
  24880. protected _restoreStateValues(): boolean;
  24881. /**
  24882. * Restored camera state. You must call storeState() first.
  24883. * @returns true if restored and false otherwise
  24884. */
  24885. restoreState(): boolean;
  24886. /**
  24887. * Gets the class name of the camera.
  24888. * @returns the class name
  24889. */
  24890. getClassName(): string;
  24891. /** @hidden */
  24892. readonly _isCamera: boolean;
  24893. /**
  24894. * Gets a string representation of the camera useful for debug purpose.
  24895. * @param fullDetails Defines that a more verboe level of logging is required
  24896. * @returns the string representation
  24897. */
  24898. toString(fullDetails?: boolean): string;
  24899. /**
  24900. * Gets the current world space position of the camera.
  24901. */
  24902. readonly globalPosition: Vector3;
  24903. /**
  24904. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24905. * @returns the active meshe list
  24906. */
  24907. getActiveMeshes(): SmartArray<AbstractMesh>;
  24908. /**
  24909. * Check wether a mesh is part of the current active mesh list of the camera
  24910. * @param mesh Defines the mesh to check
  24911. * @returns true if active, false otherwise
  24912. */
  24913. isActiveMesh(mesh: Mesh): boolean;
  24914. /**
  24915. * Is this camera ready to be used/rendered
  24916. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24917. * @return true if the camera is ready
  24918. */
  24919. isReady(completeCheck?: boolean): boolean;
  24920. /** @hidden */
  24921. _initCache(): void;
  24922. /** @hidden */
  24923. _updateCache(ignoreParentClass?: boolean): void;
  24924. /** @hidden */
  24925. _isSynchronized(): boolean;
  24926. /** @hidden */
  24927. _isSynchronizedViewMatrix(): boolean;
  24928. /** @hidden */
  24929. _isSynchronizedProjectionMatrix(): boolean;
  24930. /**
  24931. * Attach the input controls to a specific dom element to get the input from.
  24932. * @param element Defines the element the controls should be listened from
  24933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24934. */
  24935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24936. /**
  24937. * Detach the current controls from the specified dom element.
  24938. * @param element Defines the element to stop listening the inputs from
  24939. */
  24940. detachControl(element: HTMLElement): void;
  24941. /**
  24942. * Update the camera state according to the different inputs gathered during the frame.
  24943. */
  24944. update(): void;
  24945. /** @hidden */
  24946. _checkInputs(): void;
  24947. /** @hidden */
  24948. readonly rigCameras: Camera[];
  24949. /**
  24950. * Gets the post process used by the rig cameras
  24951. */
  24952. readonly rigPostProcess: Nullable<PostProcess>;
  24953. /**
  24954. * Internal, gets the first post proces.
  24955. * @returns the first post process to be run on this camera.
  24956. */
  24957. _getFirstPostProcess(): Nullable<PostProcess>;
  24958. private _cascadePostProcessesToRigCams;
  24959. /**
  24960. * Attach a post process to the camera.
  24961. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24962. * @param postProcess The post process to attach to the camera
  24963. * @param insertAt The position of the post process in case several of them are in use in the scene
  24964. * @returns the position the post process has been inserted at
  24965. */
  24966. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24967. /**
  24968. * Detach a post process to the camera.
  24969. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24970. * @param postProcess The post process to detach from the camera
  24971. */
  24972. detachPostProcess(postProcess: PostProcess): void;
  24973. /**
  24974. * Gets the current world matrix of the camera
  24975. */
  24976. getWorldMatrix(): Matrix;
  24977. /** @hidden */
  24978. _getViewMatrix(): Matrix;
  24979. /**
  24980. * Gets the current view matrix of the camera.
  24981. * @param force forces the camera to recompute the matrix without looking at the cached state
  24982. * @returns the view matrix
  24983. */
  24984. getViewMatrix(force?: boolean): Matrix;
  24985. /**
  24986. * Freeze the projection matrix.
  24987. * It will prevent the cache check of the camera projection compute and can speed up perf
  24988. * if no parameter of the camera are meant to change
  24989. * @param projection Defines manually a projection if necessary
  24990. */
  24991. freezeProjectionMatrix(projection?: Matrix): void;
  24992. /**
  24993. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24994. */
  24995. unfreezeProjectionMatrix(): void;
  24996. /**
  24997. * Gets the current projection matrix of the camera.
  24998. * @param force forces the camera to recompute the matrix without looking at the cached state
  24999. * @returns the projection matrix
  25000. */
  25001. getProjectionMatrix(force?: boolean): Matrix;
  25002. /**
  25003. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25004. * @returns a Matrix
  25005. */
  25006. getTransformationMatrix(): Matrix;
  25007. private _updateFrustumPlanes;
  25008. /**
  25009. * Checks if a cullable object (mesh...) is in the camera frustum
  25010. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25011. * @param target The object to check
  25012. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25013. * @returns true if the object is in frustum otherwise false
  25014. */
  25015. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25016. /**
  25017. * Checks if a cullable object (mesh...) is in the camera frustum
  25018. * Unlike isInFrustum this cheks the full bounding box
  25019. * @param target The object to check
  25020. * @returns true if the object is in frustum otherwise false
  25021. */
  25022. isCompletelyInFrustum(target: ICullable): boolean;
  25023. /**
  25024. * Gets a ray in the forward direction from the camera.
  25025. * @param length Defines the length of the ray to create
  25026. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25027. * @param origin Defines the start point of the ray which defaults to the camera position
  25028. * @returns the forward ray
  25029. */
  25030. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25031. /**
  25032. * Releases resources associated with this node.
  25033. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25034. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25035. */
  25036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25037. /** @hidden */
  25038. _isLeftCamera: boolean;
  25039. /**
  25040. * Gets the left camera of a rig setup in case of Rigged Camera
  25041. */
  25042. readonly isLeftCamera: boolean;
  25043. /** @hidden */
  25044. _isRightCamera: boolean;
  25045. /**
  25046. * Gets the right camera of a rig setup in case of Rigged Camera
  25047. */
  25048. readonly isRightCamera: boolean;
  25049. /**
  25050. * Gets the left camera of a rig setup in case of Rigged Camera
  25051. */
  25052. readonly leftCamera: Nullable<FreeCamera>;
  25053. /**
  25054. * Gets the right camera of a rig setup in case of Rigged Camera
  25055. */
  25056. readonly rightCamera: Nullable<FreeCamera>;
  25057. /**
  25058. * Gets the left camera target of a rig setup in case of Rigged Camera
  25059. * @returns the target position
  25060. */
  25061. getLeftTarget(): Nullable<Vector3>;
  25062. /**
  25063. * Gets the right camera target of a rig setup in case of Rigged Camera
  25064. * @returns the target position
  25065. */
  25066. getRightTarget(): Nullable<Vector3>;
  25067. /**
  25068. * @hidden
  25069. */
  25070. setCameraRigMode(mode: number, rigParams: any): void;
  25071. /** @hidden */
  25072. static _setStereoscopicRigMode(camera: Camera): void;
  25073. /** @hidden */
  25074. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25075. /** @hidden */
  25076. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25077. /** @hidden */
  25078. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25079. /** @hidden */
  25080. _getVRProjectionMatrix(): Matrix;
  25081. protected _updateCameraRotationMatrix(): void;
  25082. protected _updateWebVRCameraRotationMatrix(): void;
  25083. /**
  25084. * This function MUST be overwritten by the different WebVR cameras available.
  25085. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25086. * @hidden
  25087. */
  25088. _getWebVRProjectionMatrix(): Matrix;
  25089. /**
  25090. * This function MUST be overwritten by the different WebVR cameras available.
  25091. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25092. * @hidden
  25093. */
  25094. _getWebVRViewMatrix(): Matrix;
  25095. /** @hidden */
  25096. setCameraRigParameter(name: string, value: any): void;
  25097. /**
  25098. * needs to be overridden by children so sub has required properties to be copied
  25099. * @hidden
  25100. */
  25101. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25102. /**
  25103. * May need to be overridden by children
  25104. * @hidden
  25105. */
  25106. _updateRigCameras(): void;
  25107. /** @hidden */
  25108. _setupInputs(): void;
  25109. /**
  25110. * Serialiaze the camera setup to a json represention
  25111. * @returns the JSON representation
  25112. */
  25113. serialize(): any;
  25114. /**
  25115. * Clones the current camera.
  25116. * @param name The cloned camera name
  25117. * @returns the cloned camera
  25118. */
  25119. clone(name: string): Camera;
  25120. /**
  25121. * Gets the direction of the camera relative to a given local axis.
  25122. * @param localAxis Defines the reference axis to provide a relative direction.
  25123. * @return the direction
  25124. */
  25125. getDirection(localAxis: Vector3): Vector3;
  25126. /**
  25127. * Returns the current camera absolute rotation
  25128. */
  25129. readonly absoluteRotation: Quaternion;
  25130. /**
  25131. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25132. * @param localAxis Defines the reference axis to provide a relative direction.
  25133. * @param result Defines the vector to store the result in
  25134. */
  25135. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25136. /**
  25137. * Gets a camera constructor for a given camera type
  25138. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25139. * @param name The name of the camera the result will be able to instantiate
  25140. * @param scene The scene the result will construct the camera in
  25141. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25142. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25143. * @returns a factory method to construc the camera
  25144. */
  25145. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25146. /**
  25147. * Compute the world matrix of the camera.
  25148. * @returns the camera workd matrix
  25149. */
  25150. computeWorldMatrix(): Matrix;
  25151. /**
  25152. * Parse a JSON and creates the camera from the parsed information
  25153. * @param parsedCamera The JSON to parse
  25154. * @param scene The scene to instantiate the camera in
  25155. * @returns the newly constructed camera
  25156. */
  25157. static Parse(parsedCamera: any, scene: Scene): Camera;
  25158. }
  25159. }
  25160. declare module BABYLON {
  25161. /**
  25162. * Class containing static functions to help procedurally build meshes
  25163. */
  25164. export class DiscBuilder {
  25165. /**
  25166. * Creates a plane polygonal mesh. By default, this is a disc
  25167. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25168. * * 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
  25169. * * 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
  25170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25171. * * 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
  25172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25173. * @param name defines the name of the mesh
  25174. * @param options defines the options used to create the mesh
  25175. * @param scene defines the hosting scene
  25176. * @returns the plane polygonal mesh
  25177. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25178. */
  25179. static CreateDisc(name: string, options: {
  25180. radius?: number;
  25181. tessellation?: number;
  25182. arc?: number;
  25183. updatable?: boolean;
  25184. sideOrientation?: number;
  25185. frontUVs?: Vector4;
  25186. backUVs?: Vector4;
  25187. }, scene?: Nullable<Scene>): Mesh;
  25188. }
  25189. }
  25190. declare module BABYLON {
  25191. /**
  25192. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25193. *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.
  25194. * The SPS is also a particle system. It provides some methods to manage the particles.
  25195. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25196. *
  25197. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25198. */
  25199. export class SolidParticleSystem implements IDisposable {
  25200. /**
  25201. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25202. * Example : var p = SPS.particles[i];
  25203. */
  25204. particles: SolidParticle[];
  25205. /**
  25206. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25207. */
  25208. nbParticles: number;
  25209. /**
  25210. * If the particles must ever face the camera (default false). Useful for planar particles.
  25211. */
  25212. billboard: boolean;
  25213. /**
  25214. * Recompute normals when adding a shape
  25215. */
  25216. recomputeNormals: boolean;
  25217. /**
  25218. * This a counter ofr your own usage. It's not set by any SPS functions.
  25219. */
  25220. counter: number;
  25221. /**
  25222. * The SPS name. This name is also given to the underlying mesh.
  25223. */
  25224. name: string;
  25225. /**
  25226. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25227. */
  25228. mesh: Mesh;
  25229. /**
  25230. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25231. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25232. */
  25233. vars: any;
  25234. /**
  25235. * This array is populated when the SPS is set as 'pickable'.
  25236. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25237. * Each element of this array is an object `{idx: int, faceId: int}`.
  25238. * `idx` is the picked particle index in the `SPS.particles` array
  25239. * `faceId` is the picked face index counted within this particle.
  25240. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25241. */
  25242. pickedParticles: {
  25243. idx: number;
  25244. faceId: number;
  25245. }[];
  25246. /**
  25247. * This array is populated when `enableDepthSort` is set to true.
  25248. * Each element of this array is an instance of the class DepthSortedParticle.
  25249. */
  25250. depthSortedParticles: DepthSortedParticle[];
  25251. /**
  25252. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25253. * @hidden
  25254. */
  25255. _bSphereOnly: boolean;
  25256. /**
  25257. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25258. * @hidden
  25259. */
  25260. _bSphereRadiusFactor: number;
  25261. private _scene;
  25262. private _positions;
  25263. private _indices;
  25264. private _normals;
  25265. private _colors;
  25266. private _uvs;
  25267. private _indices32;
  25268. private _positions32;
  25269. private _normals32;
  25270. private _fixedNormal32;
  25271. private _colors32;
  25272. private _uvs32;
  25273. private _index;
  25274. private _updatable;
  25275. private _pickable;
  25276. private _isVisibilityBoxLocked;
  25277. private _alwaysVisible;
  25278. private _depthSort;
  25279. private _shapeCounter;
  25280. private _copy;
  25281. private _color;
  25282. private _computeParticleColor;
  25283. private _computeParticleTexture;
  25284. private _computeParticleRotation;
  25285. private _computeParticleVertex;
  25286. private _computeBoundingBox;
  25287. private _depthSortParticles;
  25288. private _camera;
  25289. private _mustUnrotateFixedNormals;
  25290. private _particlesIntersect;
  25291. private _needs32Bits;
  25292. /**
  25293. * Creates a SPS (Solid Particle System) object.
  25294. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25295. * @param scene (Scene) is the scene in which the SPS is added.
  25296. * @param options defines the options of the sps e.g.
  25297. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25298. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25299. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25300. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25301. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25302. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25303. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25304. */
  25305. constructor(name: string, scene: Scene, options?: {
  25306. updatable?: boolean;
  25307. isPickable?: boolean;
  25308. enableDepthSort?: boolean;
  25309. particleIntersection?: boolean;
  25310. boundingSphereOnly?: boolean;
  25311. bSphereRadiusFactor?: number;
  25312. });
  25313. /**
  25314. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25315. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25316. * @returns the created mesh
  25317. */
  25318. buildMesh(): Mesh;
  25319. /**
  25320. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25321. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25322. * Thus the particles generated from `digest()` have their property `position` set yet.
  25323. * @param mesh ( Mesh ) is the mesh to be digested
  25324. * @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
  25325. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25326. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25327. * @returns the current SPS
  25328. */
  25329. digest(mesh: Mesh, options?: {
  25330. facetNb?: number;
  25331. number?: number;
  25332. delta?: number;
  25333. }): SolidParticleSystem;
  25334. private _unrotateFixedNormals;
  25335. private _resetCopy;
  25336. private _meshBuilder;
  25337. private _posToShape;
  25338. private _uvsToShapeUV;
  25339. private _addParticle;
  25340. /**
  25341. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25342. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25343. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25344. * @param nb (positive integer) the number of particles to be created from this model
  25345. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25346. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25347. * @returns the number of shapes in the system
  25348. */
  25349. addShape(mesh: Mesh, nb: number, options?: {
  25350. positionFunction?: any;
  25351. vertexFunction?: any;
  25352. }): number;
  25353. private _rebuildParticle;
  25354. /**
  25355. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25356. * @returns the SPS.
  25357. */
  25358. rebuildMesh(): SolidParticleSystem;
  25359. /**
  25360. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25361. * This method calls `updateParticle()` for each particle of the SPS.
  25362. * For an animated SPS, it is usually called within the render loop.
  25363. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25364. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25365. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25366. * @returns the SPS.
  25367. */
  25368. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25369. /**
  25370. * Disposes the SPS.
  25371. */
  25372. dispose(): void;
  25373. /**
  25374. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25375. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25376. * @returns the SPS.
  25377. */
  25378. refreshVisibleSize(): SolidParticleSystem;
  25379. /**
  25380. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25381. * @param size the size (float) of the visibility box
  25382. * note : this doesn't lock the SPS mesh bounding box.
  25383. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25384. */
  25385. setVisibilityBox(size: number): void;
  25386. /**
  25387. * Gets whether the SPS as always visible or not
  25388. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25389. */
  25390. /**
  25391. * Sets the SPS as always visible or not
  25392. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25393. */
  25394. isAlwaysVisible: boolean;
  25395. /**
  25396. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25397. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25398. */
  25399. /**
  25400. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25401. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25402. */
  25403. isVisibilityBoxLocked: boolean;
  25404. /**
  25405. * Tells to `setParticles()` to compute the particle rotations or not.
  25406. * Default value : true. The SPS is faster when it's set to false.
  25407. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25408. */
  25409. /**
  25410. * Gets if `setParticles()` computes the particle rotations or not.
  25411. * Default value : true. The SPS is faster when it's set to false.
  25412. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25413. */
  25414. computeParticleRotation: boolean;
  25415. /**
  25416. * Tells to `setParticles()` to compute the particle colors or not.
  25417. * Default value : true. The SPS is faster when it's set to false.
  25418. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25419. */
  25420. /**
  25421. * Gets if `setParticles()` computes the particle colors or not.
  25422. * Default value : true. The SPS is faster when it's set to false.
  25423. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25424. */
  25425. computeParticleColor: boolean;
  25426. /**
  25427. * Gets if `setParticles()` computes the particle textures or not.
  25428. * Default value : true. The SPS is faster when it's set to false.
  25429. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25430. */
  25431. computeParticleTexture: boolean;
  25432. /**
  25433. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25434. * Default value : false. The SPS is faster when it's set to false.
  25435. * Note : the particle custom vertex positions aren't stored values.
  25436. */
  25437. /**
  25438. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25439. * Default value : false. The SPS is faster when it's set to false.
  25440. * Note : the particle custom vertex positions aren't stored values.
  25441. */
  25442. computeParticleVertex: boolean;
  25443. /**
  25444. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25445. */
  25446. /**
  25447. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25448. */
  25449. computeBoundingBox: boolean;
  25450. /**
  25451. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25452. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25453. * Default : `true`
  25454. */
  25455. /**
  25456. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25457. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25458. * Default : `true`
  25459. */
  25460. depthSortParticles: boolean;
  25461. /**
  25462. * This function does nothing. It may be overwritten to set all the particle first values.
  25463. * The SPS doesn't call this function, you may have to call it by your own.
  25464. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25465. */
  25466. initParticles(): void;
  25467. /**
  25468. * This function does nothing. It may be overwritten to recycle a particle.
  25469. * The SPS doesn't call this function, you may have to call it by your own.
  25470. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25471. * @param particle The particle to recycle
  25472. * @returns the recycled particle
  25473. */
  25474. recycleParticle(particle: SolidParticle): SolidParticle;
  25475. /**
  25476. * Updates a particle : this function should be overwritten by the user.
  25477. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25478. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25479. * @example : just set a particle position or velocity and recycle conditions
  25480. * @param particle The particle to update
  25481. * @returns the updated particle
  25482. */
  25483. updateParticle(particle: SolidParticle): SolidParticle;
  25484. /**
  25485. * Updates a vertex of a particle : it can be overwritten by the user.
  25486. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25487. * @param particle the current particle
  25488. * @param vertex the current index of the current particle
  25489. * @param pt the index of the current vertex in the particle shape
  25490. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25491. * @example : just set a vertex particle position
  25492. * @returns the updated vertex
  25493. */
  25494. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25495. /**
  25496. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25497. * This does nothing and may be overwritten by the user.
  25498. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25499. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25500. * @param update the boolean update value actually passed to setParticles()
  25501. */
  25502. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25503. /**
  25504. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25505. * This will be passed three parameters.
  25506. * This does nothing and may be overwritten by the user.
  25507. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25508. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25509. * @param update the boolean update value actually passed to setParticles()
  25510. */
  25511. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25512. }
  25513. }
  25514. declare module BABYLON {
  25515. /**
  25516. * Represents one particle of a solid particle system.
  25517. */
  25518. export class SolidParticle {
  25519. /**
  25520. * particle global index
  25521. */
  25522. idx: number;
  25523. /**
  25524. * The color of the particle
  25525. */
  25526. color: Nullable<Color4>;
  25527. /**
  25528. * The world space position of the particle.
  25529. */
  25530. position: Vector3;
  25531. /**
  25532. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25533. */
  25534. rotation: Vector3;
  25535. /**
  25536. * The world space rotation quaternion of the particle.
  25537. */
  25538. rotationQuaternion: Nullable<Quaternion>;
  25539. /**
  25540. * The scaling of the particle.
  25541. */
  25542. scaling: Vector3;
  25543. /**
  25544. * The uvs of the particle.
  25545. */
  25546. uvs: Vector4;
  25547. /**
  25548. * The current speed of the particle.
  25549. */
  25550. velocity: Vector3;
  25551. /**
  25552. * The pivot point in the particle local space.
  25553. */
  25554. pivot: Vector3;
  25555. /**
  25556. * Must the particle be translated from its pivot point in its local space ?
  25557. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25558. * Default : false
  25559. */
  25560. translateFromPivot: boolean;
  25561. /**
  25562. * Is the particle active or not ?
  25563. */
  25564. alive: boolean;
  25565. /**
  25566. * Is the particle visible or not ?
  25567. */
  25568. isVisible: boolean;
  25569. /**
  25570. * Index of this particle in the global "positions" array (Internal use)
  25571. * @hidden
  25572. */
  25573. _pos: number;
  25574. /**
  25575. * @hidden Index of this particle in the global "indices" array (Internal use)
  25576. */
  25577. _ind: number;
  25578. /**
  25579. * @hidden ModelShape of this particle (Internal use)
  25580. */
  25581. _model: ModelShape;
  25582. /**
  25583. * ModelShape id of this particle
  25584. */
  25585. shapeId: number;
  25586. /**
  25587. * Index of the particle in its shape id
  25588. */
  25589. idxInShape: number;
  25590. /**
  25591. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25592. */
  25593. _modelBoundingInfo: BoundingInfo;
  25594. /**
  25595. * @hidden Particle BoundingInfo object (Internal use)
  25596. */
  25597. _boundingInfo: BoundingInfo;
  25598. /**
  25599. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25600. */
  25601. _sps: SolidParticleSystem;
  25602. /**
  25603. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25604. */
  25605. _stillInvisible: boolean;
  25606. /**
  25607. * @hidden Last computed particle rotation matrix
  25608. */
  25609. _rotationMatrix: number[];
  25610. /**
  25611. * Parent particle Id, if any.
  25612. * Default null.
  25613. */
  25614. parentId: Nullable<number>;
  25615. /**
  25616. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25617. * The possible values are :
  25618. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25619. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25620. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25621. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25622. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25623. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25624. * */
  25625. cullingStrategy: number;
  25626. /**
  25627. * @hidden Internal global position in the SPS.
  25628. */
  25629. _globalPosition: Vector3;
  25630. /**
  25631. * Creates a Solid Particle object.
  25632. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25633. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25634. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25635. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25636. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25637. * @param shapeId (integer) is the model shape identifier in the SPS.
  25638. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25639. * @param sps defines the sps it is associated to
  25640. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25641. */
  25642. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25643. /**
  25644. * Legacy support, changed scale to scaling
  25645. */
  25646. /**
  25647. * Legacy support, changed scale to scaling
  25648. */
  25649. scale: Vector3;
  25650. /**
  25651. * Legacy support, changed quaternion to rotationQuaternion
  25652. */
  25653. /**
  25654. * Legacy support, changed quaternion to rotationQuaternion
  25655. */
  25656. quaternion: Nullable<Quaternion>;
  25657. /**
  25658. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25659. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25660. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25661. * @returns true if it intersects
  25662. */
  25663. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25664. /**
  25665. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25666. * A particle is in the frustum if its bounding box intersects the frustum
  25667. * @param frustumPlanes defines the frustum to test
  25668. * @returns true if the particle is in the frustum planes
  25669. */
  25670. isInFrustum(frustumPlanes: Plane[]): boolean;
  25671. /**
  25672. * get the rotation matrix of the particle
  25673. * @hidden
  25674. */
  25675. getRotationMatrix(m: Matrix): void;
  25676. }
  25677. /**
  25678. * Represents the shape of the model used by one particle of a solid particle system.
  25679. * SPS internal tool, don't use it manually.
  25680. */
  25681. export class ModelShape {
  25682. /**
  25683. * The shape id
  25684. * @hidden
  25685. */
  25686. shapeID: number;
  25687. /**
  25688. * flat array of model positions (internal use)
  25689. * @hidden
  25690. */
  25691. _shape: Vector3[];
  25692. /**
  25693. * flat array of model UVs (internal use)
  25694. * @hidden
  25695. */
  25696. _shapeUV: number[];
  25697. /**
  25698. * length of the shape in the model indices array (internal use)
  25699. * @hidden
  25700. */
  25701. _indicesLength: number;
  25702. /**
  25703. * Custom position function (internal use)
  25704. * @hidden
  25705. */
  25706. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25707. /**
  25708. * Custom vertex function (internal use)
  25709. * @hidden
  25710. */
  25711. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25712. /**
  25713. * 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.
  25714. * SPS internal tool, don't use it manually.
  25715. * @hidden
  25716. */
  25717. 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>);
  25718. }
  25719. /**
  25720. * Represents a Depth Sorted Particle in the solid particle system.
  25721. */
  25722. export class DepthSortedParticle {
  25723. /**
  25724. * Index of the particle in the "indices" array
  25725. */
  25726. ind: number;
  25727. /**
  25728. * Length of the particle shape in the "indices" array
  25729. */
  25730. indicesLength: number;
  25731. /**
  25732. * Squared distance from the particle to the camera
  25733. */
  25734. sqDistance: number;
  25735. }
  25736. }
  25737. declare module BABYLON {
  25738. /**
  25739. * @hidden
  25740. */
  25741. export class _MeshCollisionData {
  25742. _checkCollisions: boolean;
  25743. _collisionMask: number;
  25744. _collisionGroup: number;
  25745. _collider: Nullable<Collider>;
  25746. _oldPositionForCollisions: Vector3;
  25747. _diffPositionForCollisions: Vector3;
  25748. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25749. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25750. }
  25751. }
  25752. declare module BABYLON {
  25753. /** @hidden */
  25754. class _FacetDataStorage {
  25755. facetPositions: Vector3[];
  25756. facetNormals: Vector3[];
  25757. facetPartitioning: number[][];
  25758. facetNb: number;
  25759. partitioningSubdivisions: number;
  25760. partitioningBBoxRatio: number;
  25761. facetDataEnabled: boolean;
  25762. facetParameters: any;
  25763. bbSize: Vector3;
  25764. subDiv: {
  25765. max: number;
  25766. X: number;
  25767. Y: number;
  25768. Z: number;
  25769. };
  25770. facetDepthSort: boolean;
  25771. facetDepthSortEnabled: boolean;
  25772. depthSortedIndices: IndicesArray;
  25773. depthSortedFacets: {
  25774. ind: number;
  25775. sqDistance: number;
  25776. }[];
  25777. facetDepthSortFunction: (f1: {
  25778. ind: number;
  25779. sqDistance: number;
  25780. }, f2: {
  25781. ind: number;
  25782. sqDistance: number;
  25783. }) => number;
  25784. facetDepthSortFrom: Vector3;
  25785. facetDepthSortOrigin: Vector3;
  25786. invertedMatrix: Matrix;
  25787. }
  25788. /**
  25789. * @hidden
  25790. **/
  25791. class _InternalAbstractMeshDataInfo {
  25792. _hasVertexAlpha: boolean;
  25793. _useVertexColors: boolean;
  25794. _numBoneInfluencers: number;
  25795. _applyFog: boolean;
  25796. _receiveShadows: boolean;
  25797. _facetData: _FacetDataStorage;
  25798. _visibility: number;
  25799. _skeleton: Nullable<Skeleton>;
  25800. _layerMask: number;
  25801. _computeBonesUsingShaders: boolean;
  25802. _isActive: boolean;
  25803. _onlyForInstances: boolean;
  25804. _isActiveIntermediate: boolean;
  25805. _onlyForInstancesIntermediate: boolean;
  25806. }
  25807. /**
  25808. * Class used to store all common mesh properties
  25809. */
  25810. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25811. /** No occlusion */
  25812. static OCCLUSION_TYPE_NONE: number;
  25813. /** Occlusion set to optimisitic */
  25814. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25815. /** Occlusion set to strict */
  25816. static OCCLUSION_TYPE_STRICT: number;
  25817. /** Use an accurante occlusion algorithm */
  25818. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25819. /** Use a conservative occlusion algorithm */
  25820. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25821. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25822. * Test order :
  25823. * Is the bounding sphere outside the frustum ?
  25824. * If not, are the bounding box vertices outside the frustum ?
  25825. * It not, then the cullable object is in the frustum.
  25826. */
  25827. static readonly CULLINGSTRATEGY_STANDARD: number;
  25828. /** Culling strategy : Bounding Sphere Only.
  25829. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25830. * It's also less accurate than the standard because some not visible objects can still be selected.
  25831. * Test : is the bounding sphere outside the frustum ?
  25832. * If not, then the cullable object is in the frustum.
  25833. */
  25834. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25835. /** Culling strategy : Optimistic Inclusion.
  25836. * This in an inclusion test first, then the standard exclusion test.
  25837. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25838. * 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.
  25839. * Anyway, it's as accurate as the standard strategy.
  25840. * Test :
  25841. * Is the cullable object bounding sphere center in the frustum ?
  25842. * If not, apply the default culling strategy.
  25843. */
  25844. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25845. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25846. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25847. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25848. * 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.
  25849. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25850. * Test :
  25851. * Is the cullable object bounding sphere center in the frustum ?
  25852. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25853. */
  25854. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25855. /**
  25856. * No billboard
  25857. */
  25858. static readonly BILLBOARDMODE_NONE: number;
  25859. /** Billboard on X axis */
  25860. static readonly BILLBOARDMODE_X: number;
  25861. /** Billboard on Y axis */
  25862. static readonly BILLBOARDMODE_Y: number;
  25863. /** Billboard on Z axis */
  25864. static readonly BILLBOARDMODE_Z: number;
  25865. /** Billboard on all axes */
  25866. static readonly BILLBOARDMODE_ALL: number;
  25867. /** Billboard on using position instead of orientation */
  25868. static readonly BILLBOARDMODE_USE_POSITION: number;
  25869. /** @hidden */
  25870. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25871. /**
  25872. * The culling strategy to use to check whether the mesh must be rendered or not.
  25873. * This value can be changed at any time and will be used on the next render mesh selection.
  25874. * The possible values are :
  25875. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25876. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25877. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25878. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25879. * Please read each static variable documentation to get details about the culling process.
  25880. * */
  25881. cullingStrategy: number;
  25882. /**
  25883. * Gets the number of facets in the mesh
  25884. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25885. */
  25886. readonly facetNb: number;
  25887. /**
  25888. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25890. */
  25891. partitioningSubdivisions: number;
  25892. /**
  25893. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25894. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25896. */
  25897. partitioningBBoxRatio: number;
  25898. /**
  25899. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25900. * Works only for updatable meshes.
  25901. * Doesn't work with multi-materials
  25902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25903. */
  25904. mustDepthSortFacets: boolean;
  25905. /**
  25906. * The location (Vector3) where the facet depth sort must be computed from.
  25907. * By default, the active camera position.
  25908. * Used only when facet depth sort is enabled
  25909. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25910. */
  25911. facetDepthSortFrom: Vector3;
  25912. /**
  25913. * gets a boolean indicating if facetData is enabled
  25914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25915. */
  25916. readonly isFacetDataEnabled: boolean;
  25917. /** @hidden */
  25918. _updateNonUniformScalingState(value: boolean): boolean;
  25919. /**
  25920. * An event triggered when this mesh collides with another one
  25921. */
  25922. onCollideObservable: Observable<AbstractMesh>;
  25923. /** Set a function to call when this mesh collides with another one */
  25924. onCollide: () => void;
  25925. /**
  25926. * An event triggered when the collision's position changes
  25927. */
  25928. onCollisionPositionChangeObservable: Observable<Vector3>;
  25929. /** Set a function to call when the collision's position changes */
  25930. onCollisionPositionChange: () => void;
  25931. /**
  25932. * An event triggered when material is changed
  25933. */
  25934. onMaterialChangedObservable: Observable<AbstractMesh>;
  25935. /**
  25936. * Gets or sets the orientation for POV movement & rotation
  25937. */
  25938. definedFacingForward: boolean;
  25939. /** @hidden */
  25940. _occlusionQuery: Nullable<WebGLQuery>;
  25941. /** @hidden */
  25942. _renderingGroup: Nullable<RenderingGroup>;
  25943. /**
  25944. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25945. */
  25946. /**
  25947. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25948. */
  25949. visibility: number;
  25950. /** Gets or sets the alpha index used to sort transparent meshes
  25951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25952. */
  25953. alphaIndex: number;
  25954. /**
  25955. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25956. */
  25957. isVisible: boolean;
  25958. /**
  25959. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25960. */
  25961. isPickable: boolean;
  25962. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25963. showSubMeshesBoundingBox: boolean;
  25964. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25965. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25966. */
  25967. isBlocker: boolean;
  25968. /**
  25969. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25970. */
  25971. enablePointerMoveEvents: boolean;
  25972. /**
  25973. * Specifies the rendering group id for this mesh (0 by default)
  25974. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25975. */
  25976. renderingGroupId: number;
  25977. private _material;
  25978. /** Gets or sets current material */
  25979. material: Nullable<Material>;
  25980. /**
  25981. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25982. * @see http://doc.babylonjs.com/babylon101/shadows
  25983. */
  25984. receiveShadows: boolean;
  25985. /** Defines color to use when rendering outline */
  25986. outlineColor: Color3;
  25987. /** Define width to use when rendering outline */
  25988. outlineWidth: number;
  25989. /** Defines color to use when rendering overlay */
  25990. overlayColor: Color3;
  25991. /** Defines alpha to use when rendering overlay */
  25992. overlayAlpha: number;
  25993. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25994. hasVertexAlpha: boolean;
  25995. /** 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) */
  25996. useVertexColors: boolean;
  25997. /**
  25998. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25999. */
  26000. computeBonesUsingShaders: boolean;
  26001. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26002. numBoneInfluencers: number;
  26003. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26004. applyFog: boolean;
  26005. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26006. useOctreeForRenderingSelection: boolean;
  26007. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26008. useOctreeForPicking: boolean;
  26009. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26010. useOctreeForCollisions: boolean;
  26011. /**
  26012. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26013. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26014. */
  26015. layerMask: number;
  26016. /**
  26017. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26018. */
  26019. alwaysSelectAsActiveMesh: boolean;
  26020. /**
  26021. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26022. */
  26023. doNotSyncBoundingInfo: boolean;
  26024. /**
  26025. * Gets or sets the current action manager
  26026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26027. */
  26028. actionManager: Nullable<AbstractActionManager>;
  26029. private _meshCollisionData;
  26030. /**
  26031. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26032. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26033. */
  26034. ellipsoid: Vector3;
  26035. /**
  26036. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26037. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26038. */
  26039. ellipsoidOffset: Vector3;
  26040. /**
  26041. * Gets or sets a collision mask used to mask collisions (default is -1).
  26042. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26043. */
  26044. collisionMask: number;
  26045. /**
  26046. * Gets or sets the current collision group mask (-1 by default).
  26047. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26048. */
  26049. collisionGroup: number;
  26050. /**
  26051. * Defines edge width used when edgesRenderer is enabled
  26052. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26053. */
  26054. edgesWidth: number;
  26055. /**
  26056. * Defines edge color used when edgesRenderer is enabled
  26057. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26058. */
  26059. edgesColor: Color4;
  26060. /** @hidden */
  26061. _edgesRenderer: Nullable<IEdgesRenderer>;
  26062. /** @hidden */
  26063. _masterMesh: Nullable<AbstractMesh>;
  26064. /** @hidden */
  26065. _boundingInfo: Nullable<BoundingInfo>;
  26066. /** @hidden */
  26067. _renderId: number;
  26068. /**
  26069. * Gets or sets the list of subMeshes
  26070. * @see http://doc.babylonjs.com/how_to/multi_materials
  26071. */
  26072. subMeshes: SubMesh[];
  26073. /** @hidden */
  26074. _intersectionsInProgress: AbstractMesh[];
  26075. /** @hidden */
  26076. _unIndexed: boolean;
  26077. /** @hidden */
  26078. _lightSources: Light[];
  26079. /** Gets the list of lights affecting that mesh */
  26080. readonly lightSources: Light[];
  26081. /** @hidden */
  26082. readonly _positions: Nullable<Vector3[]>;
  26083. /** @hidden */
  26084. _waitingData: {
  26085. lods: Nullable<any>;
  26086. actions: Nullable<any>;
  26087. freezeWorldMatrix: Nullable<boolean>;
  26088. };
  26089. /** @hidden */
  26090. _bonesTransformMatrices: Nullable<Float32Array>;
  26091. /** @hidden */
  26092. _transformMatrixTexture: Nullable<RawTexture>;
  26093. /**
  26094. * Gets or sets a skeleton to apply skining transformations
  26095. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26096. */
  26097. skeleton: Nullable<Skeleton>;
  26098. /**
  26099. * An event triggered when the mesh is rebuilt.
  26100. */
  26101. onRebuildObservable: Observable<AbstractMesh>;
  26102. /**
  26103. * Creates a new AbstractMesh
  26104. * @param name defines the name of the mesh
  26105. * @param scene defines the hosting scene
  26106. */
  26107. constructor(name: string, scene?: Nullable<Scene>);
  26108. /**
  26109. * Returns the string "AbstractMesh"
  26110. * @returns "AbstractMesh"
  26111. */
  26112. getClassName(): string;
  26113. /**
  26114. * Gets a string representation of the current mesh
  26115. * @param fullDetails defines a boolean indicating if full details must be included
  26116. * @returns a string representation of the current mesh
  26117. */
  26118. toString(fullDetails?: boolean): string;
  26119. /**
  26120. * @hidden
  26121. */
  26122. protected _getEffectiveParent(): Nullable<Node>;
  26123. /** @hidden */
  26124. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26125. /** @hidden */
  26126. _rebuild(): void;
  26127. /** @hidden */
  26128. _resyncLightSources(): void;
  26129. /** @hidden */
  26130. _resyncLighSource(light: Light): void;
  26131. /** @hidden */
  26132. _unBindEffect(): void;
  26133. /** @hidden */
  26134. _removeLightSource(light: Light, dispose: boolean): void;
  26135. private _markSubMeshesAsDirty;
  26136. /** @hidden */
  26137. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26138. /** @hidden */
  26139. _markSubMeshesAsAttributesDirty(): void;
  26140. /** @hidden */
  26141. _markSubMeshesAsMiscDirty(): void;
  26142. /**
  26143. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26144. */
  26145. scaling: Vector3;
  26146. /**
  26147. * Returns true if the mesh is blocked. Implemented by child classes
  26148. */
  26149. readonly isBlocked: boolean;
  26150. /**
  26151. * Returns the mesh itself by default. Implemented by child classes
  26152. * @param camera defines the camera to use to pick the right LOD level
  26153. * @returns the currentAbstractMesh
  26154. */
  26155. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26156. /**
  26157. * Returns 0 by default. Implemented by child classes
  26158. * @returns an integer
  26159. */
  26160. getTotalVertices(): number;
  26161. /**
  26162. * Returns a positive integer : the total number of indices in this mesh geometry.
  26163. * @returns the numner of indices or zero if the mesh has no geometry.
  26164. */
  26165. getTotalIndices(): number;
  26166. /**
  26167. * Returns null by default. Implemented by child classes
  26168. * @returns null
  26169. */
  26170. getIndices(): Nullable<IndicesArray>;
  26171. /**
  26172. * Returns the array of the requested vertex data kind. Implemented by child classes
  26173. * @param kind defines the vertex data kind to use
  26174. * @returns null
  26175. */
  26176. getVerticesData(kind: string): Nullable<FloatArray>;
  26177. /**
  26178. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26179. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26180. * Note that a new underlying VertexBuffer object is created each call.
  26181. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26182. * @param kind defines vertex data kind:
  26183. * * VertexBuffer.PositionKind
  26184. * * VertexBuffer.UVKind
  26185. * * VertexBuffer.UV2Kind
  26186. * * VertexBuffer.UV3Kind
  26187. * * VertexBuffer.UV4Kind
  26188. * * VertexBuffer.UV5Kind
  26189. * * VertexBuffer.UV6Kind
  26190. * * VertexBuffer.ColorKind
  26191. * * VertexBuffer.MatricesIndicesKind
  26192. * * VertexBuffer.MatricesIndicesExtraKind
  26193. * * VertexBuffer.MatricesWeightsKind
  26194. * * VertexBuffer.MatricesWeightsExtraKind
  26195. * @param data defines the data source
  26196. * @param updatable defines if the data must be flagged as updatable (or static)
  26197. * @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
  26198. * @returns the current mesh
  26199. */
  26200. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26201. /**
  26202. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26203. * If the mesh has no geometry, it is simply returned as it is.
  26204. * @param kind defines vertex data kind:
  26205. * * VertexBuffer.PositionKind
  26206. * * VertexBuffer.UVKind
  26207. * * VertexBuffer.UV2Kind
  26208. * * VertexBuffer.UV3Kind
  26209. * * VertexBuffer.UV4Kind
  26210. * * VertexBuffer.UV5Kind
  26211. * * VertexBuffer.UV6Kind
  26212. * * VertexBuffer.ColorKind
  26213. * * VertexBuffer.MatricesIndicesKind
  26214. * * VertexBuffer.MatricesIndicesExtraKind
  26215. * * VertexBuffer.MatricesWeightsKind
  26216. * * VertexBuffer.MatricesWeightsExtraKind
  26217. * @param data defines the data source
  26218. * @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
  26219. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26220. * @returns the current mesh
  26221. */
  26222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26223. /**
  26224. * Sets the mesh indices,
  26225. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26226. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26227. * @param totalVertices Defines the total number of vertices
  26228. * @returns the current mesh
  26229. */
  26230. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26231. /**
  26232. * Gets a boolean indicating if specific vertex data is present
  26233. * @param kind defines the vertex data kind to use
  26234. * @returns true is data kind is present
  26235. */
  26236. isVerticesDataPresent(kind: string): boolean;
  26237. /**
  26238. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26239. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26240. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26241. * @returns a BoundingInfo
  26242. */
  26243. getBoundingInfo(): BoundingInfo;
  26244. /**
  26245. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26246. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26247. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26248. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26249. * @returns the current mesh
  26250. */
  26251. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26252. /**
  26253. * Overwrite the current bounding info
  26254. * @param boundingInfo defines the new bounding info
  26255. * @returns the current mesh
  26256. */
  26257. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26258. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26259. readonly useBones: boolean;
  26260. /** @hidden */
  26261. _preActivate(): void;
  26262. /** @hidden */
  26263. _preActivateForIntermediateRendering(renderId: number): void;
  26264. /** @hidden */
  26265. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26266. /** @hidden */
  26267. _postActivate(): void;
  26268. /** @hidden */
  26269. _freeze(): void;
  26270. /** @hidden */
  26271. _unFreeze(): void;
  26272. /**
  26273. * Gets the current world matrix
  26274. * @returns a Matrix
  26275. */
  26276. getWorldMatrix(): Matrix;
  26277. /** @hidden */
  26278. _getWorldMatrixDeterminant(): number;
  26279. /**
  26280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26281. */
  26282. readonly isAnInstance: boolean;
  26283. /**
  26284. * Gets a boolean indicating if this mesh has instances
  26285. */
  26286. readonly hasInstances: boolean;
  26287. /**
  26288. * Perform relative position change from the point of view of behind the front of the mesh.
  26289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26290. * Supports definition of mesh facing forward or backward
  26291. * @param amountRight defines the distance on the right axis
  26292. * @param amountUp defines the distance on the up axis
  26293. * @param amountForward defines the distance on the forward axis
  26294. * @returns the current mesh
  26295. */
  26296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26297. /**
  26298. * Calculate relative position change from the point of view of behind the front of the mesh.
  26299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26300. * Supports definition of mesh facing forward or backward
  26301. * @param amountRight defines the distance on the right axis
  26302. * @param amountUp defines the distance on the up axis
  26303. * @param amountForward defines the distance on the forward axis
  26304. * @returns the new displacement vector
  26305. */
  26306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26307. /**
  26308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26309. * Supports definition of mesh facing forward or backward
  26310. * @param flipBack defines the flip
  26311. * @param twirlClockwise defines the twirl
  26312. * @param tiltRight defines the tilt
  26313. * @returns the current mesh
  26314. */
  26315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26316. /**
  26317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26318. * Supports definition of mesh facing forward or backward.
  26319. * @param flipBack defines the flip
  26320. * @param twirlClockwise defines the twirl
  26321. * @param tiltRight defines the tilt
  26322. * @returns the new rotation vector
  26323. */
  26324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26325. /**
  26326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26327. * This means the mesh underlying bounding box and sphere are recomputed.
  26328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26329. * @returns the current mesh
  26330. */
  26331. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26332. /** @hidden */
  26333. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26334. /** @hidden */
  26335. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26336. /** @hidden */
  26337. _updateBoundingInfo(): AbstractMesh;
  26338. /** @hidden */
  26339. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26340. /** @hidden */
  26341. protected _afterComputeWorldMatrix(): void;
  26342. /** @hidden */
  26343. readonly _effectiveMesh: AbstractMesh;
  26344. /**
  26345. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26346. * A mesh is in the frustum if its bounding box intersects the frustum
  26347. * @param frustumPlanes defines the frustum to test
  26348. * @returns true if the mesh is in the frustum planes
  26349. */
  26350. isInFrustum(frustumPlanes: Plane[]): boolean;
  26351. /**
  26352. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26353. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26354. * @param frustumPlanes defines the frustum to test
  26355. * @returns true if the mesh is completely in the frustum planes
  26356. */
  26357. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26358. /**
  26359. * True if the mesh intersects another mesh or a SolidParticle object
  26360. * @param mesh defines a target mesh or SolidParticle to test
  26361. * @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)
  26362. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26363. * @returns true if there is an intersection
  26364. */
  26365. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26366. /**
  26367. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26368. * @param point defines the point to test
  26369. * @returns true if there is an intersection
  26370. */
  26371. intersectsPoint(point: Vector3): boolean;
  26372. /**
  26373. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26375. */
  26376. checkCollisions: boolean;
  26377. /**
  26378. * Gets Collider object used to compute collisions (not physics)
  26379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26380. */
  26381. readonly collider: Nullable<Collider>;
  26382. /**
  26383. * Move the mesh using collision engine
  26384. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26385. * @param displacement defines the requested displacement vector
  26386. * @returns the current mesh
  26387. */
  26388. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26389. private _onCollisionPositionChange;
  26390. /** @hidden */
  26391. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26392. /** @hidden */
  26393. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26394. /** @hidden */
  26395. _checkCollision(collider: Collider): AbstractMesh;
  26396. /** @hidden */
  26397. _generatePointsArray(): boolean;
  26398. /**
  26399. * Checks if the passed Ray intersects with the mesh
  26400. * @param ray defines the ray to use
  26401. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26403. * @returns the picking info
  26404. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26405. */
  26406. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26407. /**
  26408. * Clones the current mesh
  26409. * @param name defines the mesh name
  26410. * @param newParent defines the new mesh parent
  26411. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26412. * @returns the new mesh
  26413. */
  26414. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26415. /**
  26416. * Disposes all the submeshes of the current meshnp
  26417. * @returns the current mesh
  26418. */
  26419. releaseSubMeshes(): AbstractMesh;
  26420. /**
  26421. * Releases resources associated with this abstract mesh.
  26422. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26423. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26424. */
  26425. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26426. /**
  26427. * Adds the passed mesh as a child to the current mesh
  26428. * @param mesh defines the child mesh
  26429. * @returns the current mesh
  26430. */
  26431. addChild(mesh: AbstractMesh): AbstractMesh;
  26432. /**
  26433. * Removes the passed mesh from the current mesh children list
  26434. * @param mesh defines the child mesh
  26435. * @returns the current mesh
  26436. */
  26437. removeChild(mesh: AbstractMesh): AbstractMesh;
  26438. /** @hidden */
  26439. private _initFacetData;
  26440. /**
  26441. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26442. * This method can be called within the render loop.
  26443. * 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
  26444. * @returns the current mesh
  26445. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26446. */
  26447. updateFacetData(): AbstractMesh;
  26448. /**
  26449. * Returns the facetLocalNormals array.
  26450. * The normals are expressed in the mesh local spac
  26451. * @returns an array of Vector3
  26452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26453. */
  26454. getFacetLocalNormals(): Vector3[];
  26455. /**
  26456. * Returns the facetLocalPositions array.
  26457. * The facet positions are expressed in the mesh local space
  26458. * @returns an array of Vector3
  26459. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26460. */
  26461. getFacetLocalPositions(): Vector3[];
  26462. /**
  26463. * Returns the facetLocalPartioning array
  26464. * @returns an array of array of numbers
  26465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26466. */
  26467. getFacetLocalPartitioning(): number[][];
  26468. /**
  26469. * Returns the i-th facet position in the world system.
  26470. * This method allocates a new Vector3 per call
  26471. * @param i defines the facet index
  26472. * @returns a new Vector3
  26473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26474. */
  26475. getFacetPosition(i: number): Vector3;
  26476. /**
  26477. * Sets the reference Vector3 with the i-th facet position in the world system
  26478. * @param i defines the facet index
  26479. * @param ref defines the target vector
  26480. * @returns the current mesh
  26481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26482. */
  26483. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26484. /**
  26485. * Returns the i-th facet normal in the world system.
  26486. * This method allocates a new Vector3 per call
  26487. * @param i defines the facet index
  26488. * @returns a new Vector3
  26489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26490. */
  26491. getFacetNormal(i: number): Vector3;
  26492. /**
  26493. * Sets the reference Vector3 with the i-th facet normal in the world system
  26494. * @param i defines the facet index
  26495. * @param ref defines the target vector
  26496. * @returns the current mesh
  26497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26498. */
  26499. getFacetNormalToRef(i: number, ref: Vector3): this;
  26500. /**
  26501. * 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)
  26502. * @param x defines x coordinate
  26503. * @param y defines y coordinate
  26504. * @param z defines z coordinate
  26505. * @returns the array of facet indexes
  26506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26507. */
  26508. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26509. /**
  26510. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26511. * @param projected sets as the (x,y,z) world projection on the facet
  26512. * @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
  26513. * @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
  26514. * @param x defines x coordinate
  26515. * @param y defines y coordinate
  26516. * @param z defines z coordinate
  26517. * @returns the face index if found (or null instead)
  26518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26519. */
  26520. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26521. /**
  26522. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26523. * @param projected sets as the (x,y,z) local projection on the facet
  26524. * @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
  26525. * @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
  26526. * @param x defines x coordinate
  26527. * @param y defines y coordinate
  26528. * @param z defines z coordinate
  26529. * @returns the face index if found (or null instead)
  26530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26531. */
  26532. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26533. /**
  26534. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26535. * @returns the parameters
  26536. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26537. */
  26538. getFacetDataParameters(): any;
  26539. /**
  26540. * Disables the feature FacetData and frees the related memory
  26541. * @returns the current mesh
  26542. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26543. */
  26544. disableFacetData(): AbstractMesh;
  26545. /**
  26546. * Updates the AbstractMesh indices array
  26547. * @param indices defines the data source
  26548. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26549. * @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)
  26550. * @returns the current mesh
  26551. */
  26552. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26553. /**
  26554. * Creates new normals data for the mesh
  26555. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26556. * @returns the current mesh
  26557. */
  26558. createNormals(updatable: boolean): AbstractMesh;
  26559. /**
  26560. * Align the mesh with a normal
  26561. * @param normal defines the normal to use
  26562. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26563. * @returns the current mesh
  26564. */
  26565. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26566. /** @hidden */
  26567. _checkOcclusionQuery(): boolean;
  26568. /**
  26569. * Disables the mesh edge rendering mode
  26570. * @returns the currentAbstractMesh
  26571. */
  26572. disableEdgesRendering(): AbstractMesh;
  26573. /**
  26574. * Enables the edge rendering mode on the mesh.
  26575. * This mode makes the mesh edges visible
  26576. * @param epsilon defines the maximal distance between two angles to detect a face
  26577. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26578. * @returns the currentAbstractMesh
  26579. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26580. */
  26581. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26582. }
  26583. }
  26584. declare module BABYLON {
  26585. /**
  26586. * Interface used to define ActionEvent
  26587. */
  26588. export interface IActionEvent {
  26589. /** The mesh or sprite that triggered the action */
  26590. source: any;
  26591. /** The X mouse cursor position at the time of the event */
  26592. pointerX: number;
  26593. /** The Y mouse cursor position at the time of the event */
  26594. pointerY: number;
  26595. /** The mesh that is currently pointed at (can be null) */
  26596. meshUnderPointer: Nullable<AbstractMesh>;
  26597. /** the original (browser) event that triggered the ActionEvent */
  26598. sourceEvent?: any;
  26599. /** additional data for the event */
  26600. additionalData?: any;
  26601. }
  26602. /**
  26603. * ActionEvent is the event being sent when an action is triggered.
  26604. */
  26605. export class ActionEvent implements IActionEvent {
  26606. /** The mesh or sprite that triggered the action */
  26607. source: any;
  26608. /** The X mouse cursor position at the time of the event */
  26609. pointerX: number;
  26610. /** The Y mouse cursor position at the time of the event */
  26611. pointerY: number;
  26612. /** The mesh that is currently pointed at (can be null) */
  26613. meshUnderPointer: Nullable<AbstractMesh>;
  26614. /** the original (browser) event that triggered the ActionEvent */
  26615. sourceEvent?: any;
  26616. /** additional data for the event */
  26617. additionalData?: any;
  26618. /**
  26619. * Creates a new ActionEvent
  26620. * @param source The mesh or sprite that triggered the action
  26621. * @param pointerX The X mouse cursor position at the time of the event
  26622. * @param pointerY The Y mouse cursor position at the time of the event
  26623. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26624. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26625. * @param additionalData additional data for the event
  26626. */
  26627. constructor(
  26628. /** The mesh or sprite that triggered the action */
  26629. source: any,
  26630. /** The X mouse cursor position at the time of the event */
  26631. pointerX: number,
  26632. /** The Y mouse cursor position at the time of the event */
  26633. pointerY: number,
  26634. /** The mesh that is currently pointed at (can be null) */
  26635. meshUnderPointer: Nullable<AbstractMesh>,
  26636. /** the original (browser) event that triggered the ActionEvent */
  26637. sourceEvent?: any,
  26638. /** additional data for the event */
  26639. additionalData?: any);
  26640. /**
  26641. * Helper function to auto-create an ActionEvent from a source mesh.
  26642. * @param source The source mesh that triggered the event
  26643. * @param evt The original (browser) event
  26644. * @param additionalData additional data for the event
  26645. * @returns the new ActionEvent
  26646. */
  26647. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26648. /**
  26649. * Helper function to auto-create an ActionEvent from a source sprite
  26650. * @param source The source sprite that triggered the event
  26651. * @param scene Scene associated with the sprite
  26652. * @param evt The original (browser) event
  26653. * @param additionalData additional data for the event
  26654. * @returns the new ActionEvent
  26655. */
  26656. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26657. /**
  26658. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26659. * @param scene the scene where the event occurred
  26660. * @param evt The original (browser) event
  26661. * @returns the new ActionEvent
  26662. */
  26663. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26664. /**
  26665. * Helper function to auto-create an ActionEvent from a primitive
  26666. * @param prim defines the target primitive
  26667. * @param pointerPos defines the pointer position
  26668. * @param evt The original (browser) event
  26669. * @param additionalData additional data for the event
  26670. * @returns the new ActionEvent
  26671. */
  26672. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26673. }
  26674. }
  26675. declare module BABYLON {
  26676. /**
  26677. * Abstract class used to decouple action Manager from scene and meshes.
  26678. * Do not instantiate.
  26679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26680. */
  26681. export abstract class AbstractActionManager implements IDisposable {
  26682. /** Gets the list of active triggers */
  26683. static Triggers: {
  26684. [key: string]: number;
  26685. };
  26686. /** Gets the cursor to use when hovering items */
  26687. hoverCursor: string;
  26688. /** Gets the list of actions */
  26689. actions: IAction[];
  26690. /**
  26691. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26692. */
  26693. isRecursive: boolean;
  26694. /**
  26695. * Releases all associated resources
  26696. */
  26697. abstract dispose(): void;
  26698. /**
  26699. * Does this action manager has pointer triggers
  26700. */
  26701. abstract readonly hasPointerTriggers: boolean;
  26702. /**
  26703. * Does this action manager has pick triggers
  26704. */
  26705. abstract readonly hasPickTriggers: boolean;
  26706. /**
  26707. * Process a specific trigger
  26708. * @param trigger defines the trigger to process
  26709. * @param evt defines the event details to be processed
  26710. */
  26711. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26712. /**
  26713. * Does this action manager handles actions of any of the given triggers
  26714. * @param triggers defines the triggers to be tested
  26715. * @return a boolean indicating whether one (or more) of the triggers is handled
  26716. */
  26717. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26718. /**
  26719. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26720. * speed.
  26721. * @param triggerA defines the trigger to be tested
  26722. * @param triggerB defines the trigger to be tested
  26723. * @return a boolean indicating whether one (or more) of the triggers is handled
  26724. */
  26725. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26726. /**
  26727. * Does this action manager handles actions of a given trigger
  26728. * @param trigger defines the trigger to be tested
  26729. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26730. * @return whether the trigger is handled
  26731. */
  26732. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26733. /**
  26734. * Serialize this manager to a JSON object
  26735. * @param name defines the property name to store this manager
  26736. * @returns a JSON representation of this manager
  26737. */
  26738. abstract serialize(name: string): any;
  26739. /**
  26740. * Registers an action to this action manager
  26741. * @param action defines the action to be registered
  26742. * @return the action amended (prepared) after registration
  26743. */
  26744. abstract registerAction(action: IAction): Nullable<IAction>;
  26745. /**
  26746. * Unregisters an action to this action manager
  26747. * @param action defines the action to be unregistered
  26748. * @return a boolean indicating whether the action has been unregistered
  26749. */
  26750. abstract unregisterAction(action: IAction): Boolean;
  26751. /**
  26752. * Does exist one action manager with at least one trigger
  26753. **/
  26754. static readonly HasTriggers: boolean;
  26755. /**
  26756. * Does exist one action manager with at least one pick trigger
  26757. **/
  26758. static readonly HasPickTriggers: boolean;
  26759. /**
  26760. * Does exist one action manager that handles actions of a given trigger
  26761. * @param trigger defines the trigger to be tested
  26762. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26763. **/
  26764. static HasSpecificTrigger(trigger: number): boolean;
  26765. }
  26766. }
  26767. declare module BABYLON {
  26768. /**
  26769. * Defines how a node can be built from a string name.
  26770. */
  26771. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26772. /**
  26773. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26774. */
  26775. export class Node implements IBehaviorAware<Node> {
  26776. /** @hidden */
  26777. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26778. private static _NodeConstructors;
  26779. /**
  26780. * Add a new node constructor
  26781. * @param type defines the type name of the node to construct
  26782. * @param constructorFunc defines the constructor function
  26783. */
  26784. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26785. /**
  26786. * Returns a node constructor based on type name
  26787. * @param type defines the type name
  26788. * @param name defines the new node name
  26789. * @param scene defines the hosting scene
  26790. * @param options defines optional options to transmit to constructors
  26791. * @returns the new constructor or null
  26792. */
  26793. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26794. /**
  26795. * Gets or sets the name of the node
  26796. */
  26797. name: string;
  26798. /**
  26799. * Gets or sets the id of the node
  26800. */
  26801. id: string;
  26802. /**
  26803. * Gets or sets the unique id of the node
  26804. */
  26805. uniqueId: number;
  26806. /**
  26807. * Gets or sets a string used to store user defined state for the node
  26808. */
  26809. state: string;
  26810. /**
  26811. * Gets or sets an object used to store user defined information for the node
  26812. */
  26813. metadata: any;
  26814. /**
  26815. * For internal use only. Please do not use.
  26816. */
  26817. reservedDataStore: any;
  26818. /**
  26819. * List of inspectable custom properties (used by the Inspector)
  26820. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26821. */
  26822. inspectableCustomProperties: IInspectable[];
  26823. /**
  26824. * Gets or sets a boolean used to define if the node must be serialized
  26825. */
  26826. doNotSerialize: boolean;
  26827. /** @hidden */
  26828. _isDisposed: boolean;
  26829. /**
  26830. * Gets a list of Animations associated with the node
  26831. */
  26832. animations: Animation[];
  26833. protected _ranges: {
  26834. [name: string]: Nullable<AnimationRange>;
  26835. };
  26836. /**
  26837. * Callback raised when the node is ready to be used
  26838. */
  26839. onReady: Nullable<(node: Node) => void>;
  26840. private _isEnabled;
  26841. private _isParentEnabled;
  26842. private _isReady;
  26843. /** @hidden */
  26844. _currentRenderId: number;
  26845. private _parentUpdateId;
  26846. /** @hidden */
  26847. _childUpdateId: number;
  26848. /** @hidden */
  26849. _waitingParentId: Nullable<string>;
  26850. /** @hidden */
  26851. _scene: Scene;
  26852. /** @hidden */
  26853. _cache: any;
  26854. private _parentNode;
  26855. private _children;
  26856. /** @hidden */
  26857. _worldMatrix: Matrix;
  26858. /** @hidden */
  26859. _worldMatrixDeterminant: number;
  26860. /** @hidden */
  26861. _worldMatrixDeterminantIsDirty: boolean;
  26862. /** @hidden */
  26863. private _sceneRootNodesIndex;
  26864. /**
  26865. * Gets a boolean indicating if the node has been disposed
  26866. * @returns true if the node was disposed
  26867. */
  26868. isDisposed(): boolean;
  26869. /**
  26870. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26871. * @see https://doc.babylonjs.com/how_to/parenting
  26872. */
  26873. parent: Nullable<Node>;
  26874. private addToSceneRootNodes;
  26875. private removeFromSceneRootNodes;
  26876. private _animationPropertiesOverride;
  26877. /**
  26878. * Gets or sets the animation properties override
  26879. */
  26880. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26881. /**
  26882. * Gets a string idenfifying the name of the class
  26883. * @returns "Node" string
  26884. */
  26885. getClassName(): string;
  26886. /** @hidden */
  26887. readonly _isNode: boolean;
  26888. /**
  26889. * An event triggered when the mesh is disposed
  26890. */
  26891. onDisposeObservable: Observable<Node>;
  26892. private _onDisposeObserver;
  26893. /**
  26894. * Sets a callback that will be raised when the node will be disposed
  26895. */
  26896. onDispose: () => void;
  26897. /**
  26898. * Creates a new Node
  26899. * @param name the name and id to be given to this node
  26900. * @param scene the scene this node will be added to
  26901. * @param addToRootNodes the node will be added to scene.rootNodes
  26902. */
  26903. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26904. /**
  26905. * Gets the scene of the node
  26906. * @returns a scene
  26907. */
  26908. getScene(): Scene;
  26909. /**
  26910. * Gets the engine of the node
  26911. * @returns a Engine
  26912. */
  26913. getEngine(): Engine;
  26914. private _behaviors;
  26915. /**
  26916. * Attach a behavior to the node
  26917. * @see http://doc.babylonjs.com/features/behaviour
  26918. * @param behavior defines the behavior to attach
  26919. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26920. * @returns the current Node
  26921. */
  26922. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26923. /**
  26924. * Remove an attached behavior
  26925. * @see http://doc.babylonjs.com/features/behaviour
  26926. * @param behavior defines the behavior to attach
  26927. * @returns the current Node
  26928. */
  26929. removeBehavior(behavior: Behavior<Node>): Node;
  26930. /**
  26931. * Gets the list of attached behaviors
  26932. * @see http://doc.babylonjs.com/features/behaviour
  26933. */
  26934. readonly behaviors: Behavior<Node>[];
  26935. /**
  26936. * Gets an attached behavior by name
  26937. * @param name defines the name of the behavior to look for
  26938. * @see http://doc.babylonjs.com/features/behaviour
  26939. * @returns null if behavior was not found else the requested behavior
  26940. */
  26941. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26942. /**
  26943. * Returns the latest update of the World matrix
  26944. * @returns a Matrix
  26945. */
  26946. getWorldMatrix(): Matrix;
  26947. /** @hidden */
  26948. _getWorldMatrixDeterminant(): number;
  26949. /**
  26950. * Returns directly the latest state of the mesh World matrix.
  26951. * A Matrix is returned.
  26952. */
  26953. readonly worldMatrixFromCache: Matrix;
  26954. /** @hidden */
  26955. _initCache(): void;
  26956. /** @hidden */
  26957. updateCache(force?: boolean): void;
  26958. /** @hidden */
  26959. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26960. /** @hidden */
  26961. _updateCache(ignoreParentClass?: boolean): void;
  26962. /** @hidden */
  26963. _isSynchronized(): boolean;
  26964. /** @hidden */
  26965. _markSyncedWithParent(): void;
  26966. /** @hidden */
  26967. isSynchronizedWithParent(): boolean;
  26968. /** @hidden */
  26969. isSynchronized(): boolean;
  26970. /**
  26971. * Is this node ready to be used/rendered
  26972. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26973. * @return true if the node is ready
  26974. */
  26975. isReady(completeCheck?: boolean): boolean;
  26976. /**
  26977. * Is this node enabled?
  26978. * 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
  26979. * @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
  26980. * @return whether this node (and its parent) is enabled
  26981. */
  26982. isEnabled(checkAncestors?: boolean): boolean;
  26983. /** @hidden */
  26984. protected _syncParentEnabledState(): void;
  26985. /**
  26986. * Set the enabled state of this node
  26987. * @param value defines the new enabled state
  26988. */
  26989. setEnabled(value: boolean): void;
  26990. /**
  26991. * Is this node a descendant of the given node?
  26992. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26993. * @param ancestor defines the parent node to inspect
  26994. * @returns a boolean indicating if this node is a descendant of the given node
  26995. */
  26996. isDescendantOf(ancestor: Node): boolean;
  26997. /** @hidden */
  26998. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26999. /**
  27000. * Will return all nodes that have this node as ascendant
  27001. * @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
  27002. * @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
  27003. * @return all children nodes of all types
  27004. */
  27005. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27006. /**
  27007. * Get all child-meshes of this node
  27008. * @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)
  27009. * @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
  27010. * @returns an array of AbstractMesh
  27011. */
  27012. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27013. /**
  27014. * Get all direct children of this node
  27015. * @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
  27016. * @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)
  27017. * @returns an array of Node
  27018. */
  27019. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27020. /** @hidden */
  27021. _setReady(state: boolean): void;
  27022. /**
  27023. * Get an animation by name
  27024. * @param name defines the name of the animation to look for
  27025. * @returns null if not found else the requested animation
  27026. */
  27027. getAnimationByName(name: string): Nullable<Animation>;
  27028. /**
  27029. * Creates an animation range for this node
  27030. * @param name defines the name of the range
  27031. * @param from defines the starting key
  27032. * @param to defines the end key
  27033. */
  27034. createAnimationRange(name: string, from: number, to: number): void;
  27035. /**
  27036. * Delete a specific animation range
  27037. * @param name defines the name of the range to delete
  27038. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27039. */
  27040. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27041. /**
  27042. * Get an animation range by name
  27043. * @param name defines the name of the animation range to look for
  27044. * @returns null if not found else the requested animation range
  27045. */
  27046. getAnimationRange(name: string): Nullable<AnimationRange>;
  27047. /**
  27048. * Gets the list of all animation ranges defined on this node
  27049. * @returns an array
  27050. */
  27051. getAnimationRanges(): Nullable<AnimationRange>[];
  27052. /**
  27053. * Will start the animation sequence
  27054. * @param name defines the range frames for animation sequence
  27055. * @param loop defines if the animation should loop (false by default)
  27056. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27057. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27058. * @returns the object created for this animation. If range does not exist, it will return null
  27059. */
  27060. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27061. /**
  27062. * Serialize animation ranges into a JSON compatible object
  27063. * @returns serialization object
  27064. */
  27065. serializeAnimationRanges(): any;
  27066. /**
  27067. * Computes the world matrix of the node
  27068. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27069. * @returns the world matrix
  27070. */
  27071. computeWorldMatrix(force?: boolean): Matrix;
  27072. /**
  27073. * Releases resources associated with this node.
  27074. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27075. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27076. */
  27077. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27078. /**
  27079. * Parse animation range data from a serialization object and store them into a given node
  27080. * @param node defines where to store the animation ranges
  27081. * @param parsedNode defines the serialization object to read data from
  27082. * @param scene defines the hosting scene
  27083. */
  27084. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27085. /**
  27086. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27087. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27088. * @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
  27089. * @returns the new bounding vectors
  27090. */
  27091. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27092. min: Vector3;
  27093. max: Vector3;
  27094. };
  27095. }
  27096. }
  27097. declare module BABYLON {
  27098. /**
  27099. * @hidden
  27100. */
  27101. export class _IAnimationState {
  27102. key: number;
  27103. repeatCount: number;
  27104. workValue?: any;
  27105. loopMode?: number;
  27106. offsetValue?: any;
  27107. highLimitValue?: any;
  27108. }
  27109. /**
  27110. * Class used to store any kind of animation
  27111. */
  27112. export class Animation {
  27113. /**Name of the animation */
  27114. name: string;
  27115. /**Property to animate */
  27116. targetProperty: string;
  27117. /**The frames per second of the animation */
  27118. framePerSecond: number;
  27119. /**The data type of the animation */
  27120. dataType: number;
  27121. /**The loop mode of the animation */
  27122. loopMode?: number | undefined;
  27123. /**Specifies if blending should be enabled */
  27124. enableBlending?: boolean | undefined;
  27125. /**
  27126. * Use matrix interpolation instead of using direct key value when animating matrices
  27127. */
  27128. static AllowMatricesInterpolation: boolean;
  27129. /**
  27130. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27131. */
  27132. static AllowMatrixDecomposeForInterpolation: boolean;
  27133. /**
  27134. * Stores the key frames of the animation
  27135. */
  27136. private _keys;
  27137. /**
  27138. * Stores the easing function of the animation
  27139. */
  27140. private _easingFunction;
  27141. /**
  27142. * @hidden Internal use only
  27143. */
  27144. _runtimeAnimations: RuntimeAnimation[];
  27145. /**
  27146. * The set of event that will be linked to this animation
  27147. */
  27148. private _events;
  27149. /**
  27150. * Stores an array of target property paths
  27151. */
  27152. targetPropertyPath: string[];
  27153. /**
  27154. * Stores the blending speed of the animation
  27155. */
  27156. blendingSpeed: number;
  27157. /**
  27158. * Stores the animation ranges for the animation
  27159. */
  27160. private _ranges;
  27161. /**
  27162. * @hidden Internal use
  27163. */
  27164. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27165. /**
  27166. * Sets up an animation
  27167. * @param property The property to animate
  27168. * @param animationType The animation type to apply
  27169. * @param framePerSecond The frames per second of the animation
  27170. * @param easingFunction The easing function used in the animation
  27171. * @returns The created animation
  27172. */
  27173. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27174. /**
  27175. * Create and start an animation on a node
  27176. * @param name defines the name of the global animation that will be run on all nodes
  27177. * @param node defines the root node where the animation will take place
  27178. * @param targetProperty defines property to animate
  27179. * @param framePerSecond defines the number of frame per second yo use
  27180. * @param totalFrame defines the number of frames in total
  27181. * @param from defines the initial value
  27182. * @param to defines the final value
  27183. * @param loopMode defines which loop mode you want to use (off by default)
  27184. * @param easingFunction defines the easing function to use (linear by default)
  27185. * @param onAnimationEnd defines the callback to call when animation end
  27186. * @returns the animatable created for this animation
  27187. */
  27188. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27189. /**
  27190. * Create and start an animation on a node and its descendants
  27191. * @param name defines the name of the global animation that will be run on all nodes
  27192. * @param node defines the root node where the animation will take place
  27193. * @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
  27194. * @param targetProperty defines property to animate
  27195. * @param framePerSecond defines the number of frame per second to use
  27196. * @param totalFrame defines the number of frames in total
  27197. * @param from defines the initial value
  27198. * @param to defines the final value
  27199. * @param loopMode defines which loop mode you want to use (off by default)
  27200. * @param easingFunction defines the easing function to use (linear by default)
  27201. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27202. * @returns the list of animatables created for all nodes
  27203. * @example https://www.babylonjs-playground.com/#MH0VLI
  27204. */
  27205. 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[]>;
  27206. /**
  27207. * Creates a new animation, merges it with the existing animations and starts it
  27208. * @param name Name of the animation
  27209. * @param node Node which contains the scene that begins the animations
  27210. * @param targetProperty Specifies which property to animate
  27211. * @param framePerSecond The frames per second of the animation
  27212. * @param totalFrame The total number of frames
  27213. * @param from The frame at the beginning of the animation
  27214. * @param to The frame at the end of the animation
  27215. * @param loopMode Specifies the loop mode of the animation
  27216. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27217. * @param onAnimationEnd Callback to run once the animation is complete
  27218. * @returns Nullable animation
  27219. */
  27220. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27221. /**
  27222. * Transition property of an host to the target Value
  27223. * @param property The property to transition
  27224. * @param targetValue The target Value of the property
  27225. * @param host The object where the property to animate belongs
  27226. * @param scene Scene used to run the animation
  27227. * @param frameRate Framerate (in frame/s) to use
  27228. * @param transition The transition type we want to use
  27229. * @param duration The duration of the animation, in milliseconds
  27230. * @param onAnimationEnd Callback trigger at the end of the animation
  27231. * @returns Nullable animation
  27232. */
  27233. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27234. /**
  27235. * Return the array of runtime animations currently using this animation
  27236. */
  27237. readonly runtimeAnimations: RuntimeAnimation[];
  27238. /**
  27239. * Specifies if any of the runtime animations are currently running
  27240. */
  27241. readonly hasRunningRuntimeAnimations: boolean;
  27242. /**
  27243. * Initializes the animation
  27244. * @param name Name of the animation
  27245. * @param targetProperty Property to animate
  27246. * @param framePerSecond The frames per second of the animation
  27247. * @param dataType The data type of the animation
  27248. * @param loopMode The loop mode of the animation
  27249. * @param enableBlending Specifies if blending should be enabled
  27250. */
  27251. constructor(
  27252. /**Name of the animation */
  27253. name: string,
  27254. /**Property to animate */
  27255. targetProperty: string,
  27256. /**The frames per second of the animation */
  27257. framePerSecond: number,
  27258. /**The data type of the animation */
  27259. dataType: number,
  27260. /**The loop mode of the animation */
  27261. loopMode?: number | undefined,
  27262. /**Specifies if blending should be enabled */
  27263. enableBlending?: boolean | undefined);
  27264. /**
  27265. * Converts the animation to a string
  27266. * @param fullDetails support for multiple levels of logging within scene loading
  27267. * @returns String form of the animation
  27268. */
  27269. toString(fullDetails?: boolean): string;
  27270. /**
  27271. * Add an event to this animation
  27272. * @param event Event to add
  27273. */
  27274. addEvent(event: AnimationEvent): void;
  27275. /**
  27276. * Remove all events found at the given frame
  27277. * @param frame The frame to remove events from
  27278. */
  27279. removeEvents(frame: number): void;
  27280. /**
  27281. * Retrieves all the events from the animation
  27282. * @returns Events from the animation
  27283. */
  27284. getEvents(): AnimationEvent[];
  27285. /**
  27286. * Creates an animation range
  27287. * @param name Name of the animation range
  27288. * @param from Starting frame of the animation range
  27289. * @param to Ending frame of the animation
  27290. */
  27291. createRange(name: string, from: number, to: number): void;
  27292. /**
  27293. * Deletes an animation range by name
  27294. * @param name Name of the animation range to delete
  27295. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27296. */
  27297. deleteRange(name: string, deleteFrames?: boolean): void;
  27298. /**
  27299. * Gets the animation range by name, or null if not defined
  27300. * @param name Name of the animation range
  27301. * @returns Nullable animation range
  27302. */
  27303. getRange(name: string): Nullable<AnimationRange>;
  27304. /**
  27305. * Gets the key frames from the animation
  27306. * @returns The key frames of the animation
  27307. */
  27308. getKeys(): Array<IAnimationKey>;
  27309. /**
  27310. * Gets the highest frame rate of the animation
  27311. * @returns Highest frame rate of the animation
  27312. */
  27313. getHighestFrame(): number;
  27314. /**
  27315. * Gets the easing function of the animation
  27316. * @returns Easing function of the animation
  27317. */
  27318. getEasingFunction(): IEasingFunction;
  27319. /**
  27320. * Sets the easing function of the animation
  27321. * @param easingFunction A custom mathematical formula for animation
  27322. */
  27323. setEasingFunction(easingFunction: EasingFunction): void;
  27324. /**
  27325. * Interpolates a scalar linearly
  27326. * @param startValue Start value of the animation curve
  27327. * @param endValue End value of the animation curve
  27328. * @param gradient Scalar amount to interpolate
  27329. * @returns Interpolated scalar value
  27330. */
  27331. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27332. /**
  27333. * Interpolates a scalar cubically
  27334. * @param startValue Start value of the animation curve
  27335. * @param outTangent End tangent of the animation
  27336. * @param endValue End value of the animation curve
  27337. * @param inTangent Start tangent of the animation curve
  27338. * @param gradient Scalar amount to interpolate
  27339. * @returns Interpolated scalar value
  27340. */
  27341. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27342. /**
  27343. * Interpolates a quaternion using a spherical linear interpolation
  27344. * @param startValue Start value of the animation curve
  27345. * @param endValue End value of the animation curve
  27346. * @param gradient Scalar amount to interpolate
  27347. * @returns Interpolated quaternion value
  27348. */
  27349. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27350. /**
  27351. * Interpolates a quaternion cubically
  27352. * @param startValue Start value of the animation curve
  27353. * @param outTangent End tangent of the animation curve
  27354. * @param endValue End value of the animation curve
  27355. * @param inTangent Start tangent of the animation curve
  27356. * @param gradient Scalar amount to interpolate
  27357. * @returns Interpolated quaternion value
  27358. */
  27359. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27360. /**
  27361. * Interpolates a Vector3 linearl
  27362. * @param startValue Start value of the animation curve
  27363. * @param endValue End value of the animation curve
  27364. * @param gradient Scalar amount to interpolate
  27365. * @returns Interpolated scalar value
  27366. */
  27367. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27368. /**
  27369. * Interpolates a Vector3 cubically
  27370. * @param startValue Start value of the animation curve
  27371. * @param outTangent End tangent of the animation
  27372. * @param endValue End value of the animation curve
  27373. * @param inTangent Start tangent of the animation curve
  27374. * @param gradient Scalar amount to interpolate
  27375. * @returns InterpolatedVector3 value
  27376. */
  27377. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27378. /**
  27379. * Interpolates a Vector2 linearly
  27380. * @param startValue Start value of the animation curve
  27381. * @param endValue End value of the animation curve
  27382. * @param gradient Scalar amount to interpolate
  27383. * @returns Interpolated Vector2 value
  27384. */
  27385. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27386. /**
  27387. * Interpolates a Vector2 cubically
  27388. * @param startValue Start value of the animation curve
  27389. * @param outTangent End tangent of the animation
  27390. * @param endValue End value of the animation curve
  27391. * @param inTangent Start tangent of the animation curve
  27392. * @param gradient Scalar amount to interpolate
  27393. * @returns Interpolated Vector2 value
  27394. */
  27395. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27396. /**
  27397. * Interpolates a size linearly
  27398. * @param startValue Start value of the animation curve
  27399. * @param endValue End value of the animation curve
  27400. * @param gradient Scalar amount to interpolate
  27401. * @returns Interpolated Size value
  27402. */
  27403. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27404. /**
  27405. * Interpolates a Color3 linearly
  27406. * @param startValue Start value of the animation curve
  27407. * @param endValue End value of the animation curve
  27408. * @param gradient Scalar amount to interpolate
  27409. * @returns Interpolated Color3 value
  27410. */
  27411. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27412. /**
  27413. * @hidden Internal use only
  27414. */
  27415. _getKeyValue(value: any): any;
  27416. /**
  27417. * @hidden Internal use only
  27418. */
  27419. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27420. /**
  27421. * Defines the function to use to interpolate matrices
  27422. * @param startValue defines the start matrix
  27423. * @param endValue defines the end matrix
  27424. * @param gradient defines the gradient between both matrices
  27425. * @param result defines an optional target matrix where to store the interpolation
  27426. * @returns the interpolated matrix
  27427. */
  27428. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27429. /**
  27430. * Makes a copy of the animation
  27431. * @returns Cloned animation
  27432. */
  27433. clone(): Animation;
  27434. /**
  27435. * Sets the key frames of the animation
  27436. * @param values The animation key frames to set
  27437. */
  27438. setKeys(values: Array<IAnimationKey>): void;
  27439. /**
  27440. * Serializes the animation to an object
  27441. * @returns Serialized object
  27442. */
  27443. serialize(): any;
  27444. /**
  27445. * Float animation type
  27446. */
  27447. private static _ANIMATIONTYPE_FLOAT;
  27448. /**
  27449. * Vector3 animation type
  27450. */
  27451. private static _ANIMATIONTYPE_VECTOR3;
  27452. /**
  27453. * Quaternion animation type
  27454. */
  27455. private static _ANIMATIONTYPE_QUATERNION;
  27456. /**
  27457. * Matrix animation type
  27458. */
  27459. private static _ANIMATIONTYPE_MATRIX;
  27460. /**
  27461. * Color3 animation type
  27462. */
  27463. private static _ANIMATIONTYPE_COLOR3;
  27464. /**
  27465. * Vector2 animation type
  27466. */
  27467. private static _ANIMATIONTYPE_VECTOR2;
  27468. /**
  27469. * Size animation type
  27470. */
  27471. private static _ANIMATIONTYPE_SIZE;
  27472. /**
  27473. * Relative Loop Mode
  27474. */
  27475. private static _ANIMATIONLOOPMODE_RELATIVE;
  27476. /**
  27477. * Cycle Loop Mode
  27478. */
  27479. private static _ANIMATIONLOOPMODE_CYCLE;
  27480. /**
  27481. * Constant Loop Mode
  27482. */
  27483. private static _ANIMATIONLOOPMODE_CONSTANT;
  27484. /**
  27485. * Get the float animation type
  27486. */
  27487. static readonly ANIMATIONTYPE_FLOAT: number;
  27488. /**
  27489. * Get the Vector3 animation type
  27490. */
  27491. static readonly ANIMATIONTYPE_VECTOR3: number;
  27492. /**
  27493. * Get the Vector2 animation type
  27494. */
  27495. static readonly ANIMATIONTYPE_VECTOR2: number;
  27496. /**
  27497. * Get the Size animation type
  27498. */
  27499. static readonly ANIMATIONTYPE_SIZE: number;
  27500. /**
  27501. * Get the Quaternion animation type
  27502. */
  27503. static readonly ANIMATIONTYPE_QUATERNION: number;
  27504. /**
  27505. * Get the Matrix animation type
  27506. */
  27507. static readonly ANIMATIONTYPE_MATRIX: number;
  27508. /**
  27509. * Get the Color3 animation type
  27510. */
  27511. static readonly ANIMATIONTYPE_COLOR3: number;
  27512. /**
  27513. * Get the Relative Loop Mode
  27514. */
  27515. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27516. /**
  27517. * Get the Cycle Loop Mode
  27518. */
  27519. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27520. /**
  27521. * Get the Constant Loop Mode
  27522. */
  27523. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27524. /** @hidden */
  27525. static _UniversalLerp(left: any, right: any, amount: number): any;
  27526. /**
  27527. * Parses an animation object and creates an animation
  27528. * @param parsedAnimation Parsed animation object
  27529. * @returns Animation object
  27530. */
  27531. static Parse(parsedAnimation: any): Animation;
  27532. /**
  27533. * Appends the serialized animations from the source animations
  27534. * @param source Source containing the animations
  27535. * @param destination Target to store the animations
  27536. */
  27537. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27538. }
  27539. }
  27540. declare module BABYLON {
  27541. /**
  27542. * Interface containing an array of animations
  27543. */
  27544. export interface IAnimatable {
  27545. /**
  27546. * Array of animations
  27547. */
  27548. animations: Nullable<Array<Animation>>;
  27549. }
  27550. }
  27551. declare module BABYLON {
  27552. /**
  27553. * This represents all the required information to add a fresnel effect on a material:
  27554. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27555. */
  27556. export class FresnelParameters {
  27557. private _isEnabled;
  27558. /**
  27559. * Define if the fresnel effect is enable or not.
  27560. */
  27561. isEnabled: boolean;
  27562. /**
  27563. * Define the color used on edges (grazing angle)
  27564. */
  27565. leftColor: Color3;
  27566. /**
  27567. * Define the color used on center
  27568. */
  27569. rightColor: Color3;
  27570. /**
  27571. * Define bias applied to computed fresnel term
  27572. */
  27573. bias: number;
  27574. /**
  27575. * Defined the power exponent applied to fresnel term
  27576. */
  27577. power: number;
  27578. /**
  27579. * Clones the current fresnel and its valuues
  27580. * @returns a clone fresnel configuration
  27581. */
  27582. clone(): FresnelParameters;
  27583. /**
  27584. * Serializes the current fresnel parameters to a JSON representation.
  27585. * @return the JSON serialization
  27586. */
  27587. serialize(): any;
  27588. /**
  27589. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27590. * @param parsedFresnelParameters Define the JSON representation
  27591. * @returns the parsed parameters
  27592. */
  27593. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27594. }
  27595. }
  27596. declare module BABYLON {
  27597. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27598. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27599. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27600. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27601. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27602. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27603. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27604. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27605. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27606. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27607. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27608. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27609. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27610. /**
  27611. * Decorator used to define property that can be serialized as reference to a camera
  27612. * @param sourceName defines the name of the property to decorate
  27613. */
  27614. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27615. /**
  27616. * Class used to help serialization objects
  27617. */
  27618. export class SerializationHelper {
  27619. /** @hidden */
  27620. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27621. /** @hidden */
  27622. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27623. /** @hidden */
  27624. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27625. /** @hidden */
  27626. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27627. /**
  27628. * Appends the serialized animations from the source animations
  27629. * @param source Source containing the animations
  27630. * @param destination Target to store the animations
  27631. */
  27632. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27633. /**
  27634. * Static function used to serialized a specific entity
  27635. * @param entity defines the entity to serialize
  27636. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27637. * @returns a JSON compatible object representing the serialization of the entity
  27638. */
  27639. static Serialize<T>(entity: T, serializationObject?: any): any;
  27640. /**
  27641. * Creates a new entity from a serialization data object
  27642. * @param creationFunction defines a function used to instanciated the new entity
  27643. * @param source defines the source serialization data
  27644. * @param scene defines the hosting scene
  27645. * @param rootUrl defines the root url for resources
  27646. * @returns a new entity
  27647. */
  27648. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27649. /**
  27650. * Clones an object
  27651. * @param creationFunction defines the function used to instanciate the new object
  27652. * @param source defines the source object
  27653. * @returns the cloned object
  27654. */
  27655. static Clone<T>(creationFunction: () => T, source: T): T;
  27656. /**
  27657. * Instanciates a new object based on a source one (some data will be shared between both object)
  27658. * @param creationFunction defines the function used to instanciate the new object
  27659. * @param source defines the source object
  27660. * @returns the new object
  27661. */
  27662. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27663. }
  27664. }
  27665. declare module BABYLON {
  27666. /**
  27667. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  27668. */
  27669. export interface CubeMapInfo {
  27670. /**
  27671. * The pixel array for the front face.
  27672. * This is stored in format, left to right, up to down format.
  27673. */
  27674. front: Nullable<ArrayBufferView>;
  27675. /**
  27676. * The pixel array for the back face.
  27677. * This is stored in format, left to right, up to down format.
  27678. */
  27679. back: Nullable<ArrayBufferView>;
  27680. /**
  27681. * The pixel array for the left face.
  27682. * This is stored in format, left to right, up to down format.
  27683. */
  27684. left: Nullable<ArrayBufferView>;
  27685. /**
  27686. * The pixel array for the right face.
  27687. * This is stored in format, left to right, up to down format.
  27688. */
  27689. right: Nullable<ArrayBufferView>;
  27690. /**
  27691. * The pixel array for the up face.
  27692. * This is stored in format, left to right, up to down format.
  27693. */
  27694. up: Nullable<ArrayBufferView>;
  27695. /**
  27696. * The pixel array for the down face.
  27697. * This is stored in format, left to right, up to down format.
  27698. */
  27699. down: Nullable<ArrayBufferView>;
  27700. /**
  27701. * The size of the cubemap stored.
  27702. *
  27703. * Each faces will be size * size pixels.
  27704. */
  27705. size: number;
  27706. /**
  27707. * The format of the texture.
  27708. *
  27709. * RGBA, RGB.
  27710. */
  27711. format: number;
  27712. /**
  27713. * The type of the texture data.
  27714. *
  27715. * UNSIGNED_INT, FLOAT.
  27716. */
  27717. type: number;
  27718. /**
  27719. * Specifies whether the texture is in gamma space.
  27720. */
  27721. gammaSpace: boolean;
  27722. }
  27723. /**
  27724. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  27725. */
  27726. export class PanoramaToCubeMapTools {
  27727. private static FACE_FRONT;
  27728. private static FACE_BACK;
  27729. private static FACE_RIGHT;
  27730. private static FACE_LEFT;
  27731. private static FACE_DOWN;
  27732. private static FACE_UP;
  27733. /**
  27734. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  27735. *
  27736. * @param float32Array The source data.
  27737. * @param inputWidth The width of the input panorama.
  27738. * @param inputHeight The height of the input panorama.
  27739. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  27740. * @return The cubemap data
  27741. */
  27742. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  27743. private static CreateCubemapTexture;
  27744. private static CalcProjectionSpherical;
  27745. }
  27746. }
  27747. declare module BABYLON {
  27748. /**
  27749. * Helper class dealing with the extraction of spherical polynomial dataArray
  27750. * from a cube map.
  27751. */
  27752. export class CubeMapToSphericalPolynomialTools {
  27753. private static FileFaces;
  27754. /**
  27755. * Converts a texture to the according Spherical Polynomial data.
  27756. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27757. *
  27758. * @param texture The texture to extract the information from.
  27759. * @return The Spherical Polynomial data.
  27760. */
  27761. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27762. /**
  27763. * Converts a cubemap to the according Spherical Polynomial data.
  27764. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27765. *
  27766. * @param cubeInfo The Cube map to extract the information from.
  27767. * @return The Spherical Polynomial data.
  27768. */
  27769. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27770. }
  27771. }
  27772. declare module BABYLON {
  27773. /**
  27774. * Class used to manipulate GUIDs
  27775. */
  27776. export class GUID {
  27777. /**
  27778. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27779. * Be aware Math.random() could cause collisions, but:
  27780. * "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"
  27781. * @returns a pseudo random id
  27782. */
  27783. static RandomId(): string;
  27784. }
  27785. }
  27786. declare module BABYLON {
  27787. /**
  27788. * Base class of all the textures in babylon.
  27789. * It groups all the common properties the materials, post process, lights... might need
  27790. * in order to make a correct use of the texture.
  27791. */
  27792. export class BaseTexture implements IAnimatable {
  27793. /**
  27794. * Default anisotropic filtering level for the application.
  27795. * It is set to 4 as a good tradeoff between perf and quality.
  27796. */
  27797. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27798. /**
  27799. * Gets or sets the unique id of the texture
  27800. */
  27801. uniqueId: number;
  27802. /**
  27803. * Define the name of the texture.
  27804. */
  27805. name: string;
  27806. /**
  27807. * Gets or sets an object used to store user defined information.
  27808. */
  27809. metadata: any;
  27810. /**
  27811. * For internal use only. Please do not use.
  27812. */
  27813. reservedDataStore: any;
  27814. private _hasAlpha;
  27815. /**
  27816. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27817. */
  27818. hasAlpha: boolean;
  27819. /**
  27820. * Defines if the alpha value should be determined via the rgb values.
  27821. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27822. */
  27823. getAlphaFromRGB: boolean;
  27824. /**
  27825. * Intensity or strength of the texture.
  27826. * It is commonly used by materials to fine tune the intensity of the texture
  27827. */
  27828. level: number;
  27829. /**
  27830. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27831. * This is part of the texture as textures usually maps to one uv set.
  27832. */
  27833. coordinatesIndex: number;
  27834. private _coordinatesMode;
  27835. /**
  27836. * How a texture is mapped.
  27837. *
  27838. * | Value | Type | Description |
  27839. * | ----- | ----------------------------------- | ----------- |
  27840. * | 0 | EXPLICIT_MODE | |
  27841. * | 1 | SPHERICAL_MODE | |
  27842. * | 2 | PLANAR_MODE | |
  27843. * | 3 | CUBIC_MODE | |
  27844. * | 4 | PROJECTION_MODE | |
  27845. * | 5 | SKYBOX_MODE | |
  27846. * | 6 | INVCUBIC_MODE | |
  27847. * | 7 | EQUIRECTANGULAR_MODE | |
  27848. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27849. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27850. */
  27851. coordinatesMode: number;
  27852. /**
  27853. * | Value | Type | Description |
  27854. * | ----- | ------------------ | ----------- |
  27855. * | 0 | CLAMP_ADDRESSMODE | |
  27856. * | 1 | WRAP_ADDRESSMODE | |
  27857. * | 2 | MIRROR_ADDRESSMODE | |
  27858. */
  27859. wrapU: number;
  27860. /**
  27861. * | Value | Type | Description |
  27862. * | ----- | ------------------ | ----------- |
  27863. * | 0 | CLAMP_ADDRESSMODE | |
  27864. * | 1 | WRAP_ADDRESSMODE | |
  27865. * | 2 | MIRROR_ADDRESSMODE | |
  27866. */
  27867. wrapV: number;
  27868. /**
  27869. * | Value | Type | Description |
  27870. * | ----- | ------------------ | ----------- |
  27871. * | 0 | CLAMP_ADDRESSMODE | |
  27872. * | 1 | WRAP_ADDRESSMODE | |
  27873. * | 2 | MIRROR_ADDRESSMODE | |
  27874. */
  27875. wrapR: number;
  27876. /**
  27877. * With compliant hardware and browser (supporting anisotropic filtering)
  27878. * this defines the level of anisotropic filtering in the texture.
  27879. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27880. */
  27881. anisotropicFilteringLevel: number;
  27882. /**
  27883. * Define if the texture is a cube texture or if false a 2d texture.
  27884. */
  27885. isCube: boolean;
  27886. /**
  27887. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27888. */
  27889. is3D: boolean;
  27890. /**
  27891. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27892. * HDR texture are usually stored in linear space.
  27893. * This only impacts the PBR and Background materials
  27894. */
  27895. gammaSpace: boolean;
  27896. /**
  27897. * Gets or sets whether or not the texture contains RGBD data.
  27898. */
  27899. isRGBD: boolean;
  27900. /**
  27901. * Is Z inverted in the texture (useful in a cube texture).
  27902. */
  27903. invertZ: boolean;
  27904. /**
  27905. * Are mip maps generated for this texture or not.
  27906. */
  27907. readonly noMipmap: boolean;
  27908. /**
  27909. * @hidden
  27910. */
  27911. lodLevelInAlpha: boolean;
  27912. /**
  27913. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27914. */
  27915. lodGenerationOffset: number;
  27916. /**
  27917. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27918. */
  27919. lodGenerationScale: number;
  27920. /**
  27921. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27922. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27923. * average roughness values.
  27924. */
  27925. linearSpecularLOD: boolean;
  27926. /**
  27927. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27928. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27929. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27930. */
  27931. irradianceTexture: Nullable<BaseTexture>;
  27932. /**
  27933. * Define if the texture is a render target.
  27934. */
  27935. isRenderTarget: boolean;
  27936. /**
  27937. * Define the unique id of the texture in the scene.
  27938. */
  27939. readonly uid: string;
  27940. /**
  27941. * Return a string representation of the texture.
  27942. * @returns the texture as a string
  27943. */
  27944. toString(): string;
  27945. /**
  27946. * Get the class name of the texture.
  27947. * @returns "BaseTexture"
  27948. */
  27949. getClassName(): string;
  27950. /**
  27951. * Define the list of animation attached to the texture.
  27952. */
  27953. animations: Animation[];
  27954. /**
  27955. * An event triggered when the texture is disposed.
  27956. */
  27957. onDisposeObservable: Observable<BaseTexture>;
  27958. private _onDisposeObserver;
  27959. /**
  27960. * Callback triggered when the texture has been disposed.
  27961. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27962. */
  27963. onDispose: () => void;
  27964. /**
  27965. * Define the current state of the loading sequence when in delayed load mode.
  27966. */
  27967. delayLoadState: number;
  27968. private _scene;
  27969. /** @hidden */
  27970. _texture: Nullable<InternalTexture>;
  27971. private _uid;
  27972. /**
  27973. * Define if the texture is preventinga material to render or not.
  27974. * If not and the texture is not ready, the engine will use a default black texture instead.
  27975. */
  27976. readonly isBlocking: boolean;
  27977. /**
  27978. * Instantiates a new BaseTexture.
  27979. * Base class of all the textures in babylon.
  27980. * It groups all the common properties the materials, post process, lights... might need
  27981. * in order to make a correct use of the texture.
  27982. * @param scene Define the scene the texture blongs to
  27983. */
  27984. constructor(scene: Nullable<Scene>);
  27985. /**
  27986. * Get the scene the texture belongs to.
  27987. * @returns the scene or null if undefined
  27988. */
  27989. getScene(): Nullable<Scene>;
  27990. /**
  27991. * Get the texture transform matrix used to offset tile the texture for istance.
  27992. * @returns the transformation matrix
  27993. */
  27994. getTextureMatrix(): Matrix;
  27995. /**
  27996. * Get the texture reflection matrix used to rotate/transform the reflection.
  27997. * @returns the reflection matrix
  27998. */
  27999. getReflectionTextureMatrix(): Matrix;
  28000. /**
  28001. * Get the underlying lower level texture from Babylon.
  28002. * @returns the insternal texture
  28003. */
  28004. getInternalTexture(): Nullable<InternalTexture>;
  28005. /**
  28006. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28007. * @returns true if ready or not blocking
  28008. */
  28009. isReadyOrNotBlocking(): boolean;
  28010. /**
  28011. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28012. * @returns true if fully ready
  28013. */
  28014. isReady(): boolean;
  28015. private _cachedSize;
  28016. /**
  28017. * Get the size of the texture.
  28018. * @returns the texture size.
  28019. */
  28020. getSize(): ISize;
  28021. /**
  28022. * Get the base size of the texture.
  28023. * It can be different from the size if the texture has been resized for POT for instance
  28024. * @returns the base size
  28025. */
  28026. getBaseSize(): ISize;
  28027. /**
  28028. * Update the sampling mode of the texture.
  28029. * Default is Trilinear mode.
  28030. *
  28031. * | Value | Type | Description |
  28032. * | ----- | ------------------ | ----------- |
  28033. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28034. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28035. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28036. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28037. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28038. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28039. * | 7 | NEAREST_LINEAR | |
  28040. * | 8 | NEAREST_NEAREST | |
  28041. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28042. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28043. * | 11 | LINEAR_LINEAR | |
  28044. * | 12 | LINEAR_NEAREST | |
  28045. *
  28046. * > _mag_: magnification filter (close to the viewer)
  28047. * > _min_: minification filter (far from the viewer)
  28048. * > _mip_: filter used between mip map levels
  28049. *@param samplingMode Define the new sampling mode of the texture
  28050. */
  28051. updateSamplingMode(samplingMode: number): void;
  28052. /**
  28053. * Scales the texture if is `canRescale()`
  28054. * @param ratio the resize factor we want to use to rescale
  28055. */
  28056. scale(ratio: number): void;
  28057. /**
  28058. * Get if the texture can rescale.
  28059. */
  28060. readonly canRescale: boolean;
  28061. /** @hidden */
  28062. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28063. /** @hidden */
  28064. _rebuild(): void;
  28065. /**
  28066. * Triggers the load sequence in delayed load mode.
  28067. */
  28068. delayLoad(): void;
  28069. /**
  28070. * Clones the texture.
  28071. * @returns the cloned texture
  28072. */
  28073. clone(): Nullable<BaseTexture>;
  28074. /**
  28075. * Get the texture underlying type (INT, FLOAT...)
  28076. */
  28077. readonly textureType: number;
  28078. /**
  28079. * Get the texture underlying format (RGB, RGBA...)
  28080. */
  28081. readonly textureFormat: number;
  28082. /**
  28083. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28084. * This will returns an RGBA array buffer containing either in values (0-255) or
  28085. * float values (0-1) depending of the underlying buffer type.
  28086. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28087. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28088. * @param buffer defines a user defined buffer to fill with data (can be null)
  28089. * @returns The Array buffer containing the pixels data.
  28090. */
  28091. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28092. /**
  28093. * Release and destroy the underlying lower level texture aka internalTexture.
  28094. */
  28095. releaseInternalTexture(): void;
  28096. /**
  28097. * Get the polynomial representation of the texture data.
  28098. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28099. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28100. */
  28101. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28102. /** @hidden */
  28103. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28104. /** @hidden */
  28105. readonly _lodTextureMid: Nullable<BaseTexture>;
  28106. /** @hidden */
  28107. readonly _lodTextureLow: Nullable<BaseTexture>;
  28108. /**
  28109. * Dispose the texture and release its associated resources.
  28110. */
  28111. dispose(): void;
  28112. /**
  28113. * Serialize the texture into a JSON representation that can be parsed later on.
  28114. * @returns the JSON representation of the texture
  28115. */
  28116. serialize(): any;
  28117. /**
  28118. * Helper function to be called back once a list of texture contains only ready textures.
  28119. * @param textures Define the list of textures to wait for
  28120. * @param callback Define the callback triggered once the entire list will be ready
  28121. */
  28122. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28123. }
  28124. }
  28125. declare module BABYLON {
  28126. /**
  28127. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28128. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28129. */
  28130. export class EffectFallbacks {
  28131. private _defines;
  28132. private _currentRank;
  28133. private _maxRank;
  28134. private _mesh;
  28135. /**
  28136. * Removes the fallback from the bound mesh.
  28137. */
  28138. unBindMesh(): void;
  28139. /**
  28140. * Adds a fallback on the specified property.
  28141. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28142. * @param define The name of the define in the shader
  28143. */
  28144. addFallback(rank: number, define: string): void;
  28145. /**
  28146. * Sets the mesh to use CPU skinning when needing to fallback.
  28147. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28148. * @param mesh The mesh to use the fallbacks.
  28149. */
  28150. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28151. /**
  28152. * Checks to see if more fallbacks are still availible.
  28153. */
  28154. readonly hasMoreFallbacks: boolean;
  28155. /**
  28156. * Removes the defines that should be removed when falling back.
  28157. * @param currentDefines defines the current define statements for the shader.
  28158. * @param effect defines the current effect we try to compile
  28159. * @returns The resulting defines with defines of the current rank removed.
  28160. */
  28161. reduce(currentDefines: string, effect: Effect): string;
  28162. }
  28163. /**
  28164. * Options to be used when creating an effect.
  28165. */
  28166. export class EffectCreationOptions {
  28167. /**
  28168. * Atrributes that will be used in the shader.
  28169. */
  28170. attributes: string[];
  28171. /**
  28172. * Uniform varible names that will be set in the shader.
  28173. */
  28174. uniformsNames: string[];
  28175. /**
  28176. * Uniform buffer varible names that will be set in the shader.
  28177. */
  28178. uniformBuffersNames: string[];
  28179. /**
  28180. * Sampler texture variable names that will be set in the shader.
  28181. */
  28182. samplers: string[];
  28183. /**
  28184. * Define statements that will be set in the shader.
  28185. */
  28186. defines: any;
  28187. /**
  28188. * Possible fallbacks for this effect to improve performance when needed.
  28189. */
  28190. fallbacks: Nullable<EffectFallbacks>;
  28191. /**
  28192. * Callback that will be called when the shader is compiled.
  28193. */
  28194. onCompiled: Nullable<(effect: Effect) => void>;
  28195. /**
  28196. * Callback that will be called if an error occurs during shader compilation.
  28197. */
  28198. onError: Nullable<(effect: Effect, errors: string) => void>;
  28199. /**
  28200. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28201. */
  28202. indexParameters: any;
  28203. /**
  28204. * Max number of lights that can be used in the shader.
  28205. */
  28206. maxSimultaneousLights: number;
  28207. /**
  28208. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28209. */
  28210. transformFeedbackVaryings: Nullable<string[]>;
  28211. }
  28212. /**
  28213. * Effect containing vertex and fragment shader that can be executed on an object.
  28214. */
  28215. export class Effect implements IDisposable {
  28216. /**
  28217. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28218. */
  28219. static ShadersRepository: string;
  28220. /**
  28221. * Name of the effect.
  28222. */
  28223. name: any;
  28224. /**
  28225. * String container all the define statements that should be set on the shader.
  28226. */
  28227. defines: string;
  28228. /**
  28229. * Callback that will be called when the shader is compiled.
  28230. */
  28231. onCompiled: Nullable<(effect: Effect) => void>;
  28232. /**
  28233. * Callback that will be called if an error occurs during shader compilation.
  28234. */
  28235. onError: Nullable<(effect: Effect, errors: string) => void>;
  28236. /**
  28237. * Callback that will be called when effect is bound.
  28238. */
  28239. onBind: Nullable<(effect: Effect) => void>;
  28240. /**
  28241. * Unique ID of the effect.
  28242. */
  28243. uniqueId: number;
  28244. /**
  28245. * Observable that will be called when the shader is compiled.
  28246. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28247. */
  28248. onCompileObservable: Observable<Effect>;
  28249. /**
  28250. * Observable that will be called if an error occurs during shader compilation.
  28251. */
  28252. onErrorObservable: Observable<Effect>;
  28253. /** @hidden */
  28254. _onBindObservable: Nullable<Observable<Effect>>;
  28255. /**
  28256. * Observable that will be called when effect is bound.
  28257. */
  28258. readonly onBindObservable: Observable<Effect>;
  28259. /** @hidden */
  28260. _bonesComputationForcedToCPU: boolean;
  28261. private static _uniqueIdSeed;
  28262. private _engine;
  28263. private _uniformBuffersNames;
  28264. private _uniformsNames;
  28265. private _samplerList;
  28266. private _samplers;
  28267. private _isReady;
  28268. private _compilationError;
  28269. private _attributesNames;
  28270. private _attributes;
  28271. private _uniforms;
  28272. /**
  28273. * Key for the effect.
  28274. * @hidden
  28275. */
  28276. _key: string;
  28277. private _indexParameters;
  28278. private _fallbacks;
  28279. private _vertexSourceCode;
  28280. private _fragmentSourceCode;
  28281. private _vertexSourceCodeOverride;
  28282. private _fragmentSourceCodeOverride;
  28283. private _transformFeedbackVaryings;
  28284. /**
  28285. * Compiled shader to webGL program.
  28286. * @hidden
  28287. */
  28288. _pipelineContext: Nullable<IPipelineContext>;
  28289. private _valueCache;
  28290. private static _baseCache;
  28291. /**
  28292. * Instantiates an effect.
  28293. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28294. * @param baseName Name of the effect.
  28295. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28296. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28297. * @param samplers List of sampler variables that will be passed to the shader.
  28298. * @param engine Engine to be used to render the effect
  28299. * @param defines Define statements to be added to the shader.
  28300. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28301. * @param onCompiled Callback that will be called when the shader is compiled.
  28302. * @param onError Callback that will be called if an error occurs during shader compilation.
  28303. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28304. */
  28305. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28306. private _useFinalCode;
  28307. /**
  28308. * Unique key for this effect
  28309. */
  28310. readonly key: string;
  28311. /**
  28312. * If the effect has been compiled and prepared.
  28313. * @returns if the effect is compiled and prepared.
  28314. */
  28315. isReady(): boolean;
  28316. private _isReadyInternal;
  28317. /**
  28318. * The engine the effect was initialized with.
  28319. * @returns the engine.
  28320. */
  28321. getEngine(): Engine;
  28322. /**
  28323. * The pipeline context for this effect
  28324. * @returns the associated pipeline context
  28325. */
  28326. getPipelineContext(): Nullable<IPipelineContext>;
  28327. /**
  28328. * The set of names of attribute variables for the shader.
  28329. * @returns An array of attribute names.
  28330. */
  28331. getAttributesNames(): string[];
  28332. /**
  28333. * Returns the attribute at the given index.
  28334. * @param index The index of the attribute.
  28335. * @returns The location of the attribute.
  28336. */
  28337. getAttributeLocation(index: number): number;
  28338. /**
  28339. * Returns the attribute based on the name of the variable.
  28340. * @param name of the attribute to look up.
  28341. * @returns the attribute location.
  28342. */
  28343. getAttributeLocationByName(name: string): number;
  28344. /**
  28345. * The number of attributes.
  28346. * @returns the numnber of attributes.
  28347. */
  28348. getAttributesCount(): number;
  28349. /**
  28350. * Gets the index of a uniform variable.
  28351. * @param uniformName of the uniform to look up.
  28352. * @returns the index.
  28353. */
  28354. getUniformIndex(uniformName: string): number;
  28355. /**
  28356. * Returns the attribute based on the name of the variable.
  28357. * @param uniformName of the uniform to look up.
  28358. * @returns the location of the uniform.
  28359. */
  28360. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28361. /**
  28362. * Returns an array of sampler variable names
  28363. * @returns The array of sampler variable neames.
  28364. */
  28365. getSamplers(): string[];
  28366. /**
  28367. * The error from the last compilation.
  28368. * @returns the error string.
  28369. */
  28370. getCompilationError(): string;
  28371. /**
  28372. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28373. * @param func The callback to be used.
  28374. */
  28375. executeWhenCompiled(func: (effect: Effect) => void): void;
  28376. private _checkIsReady;
  28377. /** @hidden */
  28378. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28379. /** @hidden */
  28380. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28381. /** @hidden */
  28382. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28383. /**
  28384. * Recompiles the webGL program
  28385. * @param vertexSourceCode The source code for the vertex shader.
  28386. * @param fragmentSourceCode The source code for the fragment shader.
  28387. * @param onCompiled Callback called when completed.
  28388. * @param onError Callback called on error.
  28389. * @hidden
  28390. */
  28391. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28392. /**
  28393. * Prepares the effect
  28394. * @hidden
  28395. */
  28396. _prepareEffect(): void;
  28397. private _processCompilationErrors;
  28398. /**
  28399. * Checks if the effect is supported. (Must be called after compilation)
  28400. */
  28401. readonly isSupported: boolean;
  28402. /**
  28403. * Binds a texture to the engine to be used as output of the shader.
  28404. * @param channel Name of the output variable.
  28405. * @param texture Texture to bind.
  28406. * @hidden
  28407. */
  28408. _bindTexture(channel: string, texture: InternalTexture): void;
  28409. /**
  28410. * Sets a texture on the engine to be used in the shader.
  28411. * @param channel Name of the sampler variable.
  28412. * @param texture Texture to set.
  28413. */
  28414. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28415. /**
  28416. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28417. * @param channel Name of the sampler variable.
  28418. * @param texture Texture to set.
  28419. */
  28420. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28421. /**
  28422. * Sets an array of textures on the engine to be used in the shader.
  28423. * @param channel Name of the variable.
  28424. * @param textures Textures to set.
  28425. */
  28426. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28427. /**
  28428. * 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)
  28429. * @param channel Name of the sampler variable.
  28430. * @param postProcess Post process to get the input texture from.
  28431. */
  28432. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28433. /**
  28434. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28435. * 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)
  28436. * @param channel Name of the sampler variable.
  28437. * @param postProcess Post process to get the output texture from.
  28438. */
  28439. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28440. /** @hidden */
  28441. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  28442. /** @hidden */
  28443. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28444. /** @hidden */
  28445. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28446. /** @hidden */
  28447. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28448. /**
  28449. * Binds a buffer to a uniform.
  28450. * @param buffer Buffer to bind.
  28451. * @param name Name of the uniform variable to bind to.
  28452. */
  28453. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28454. /**
  28455. * Binds block to a uniform.
  28456. * @param blockName Name of the block to bind.
  28457. * @param index Index to bind.
  28458. */
  28459. bindUniformBlock(blockName: string, index: number): void;
  28460. /**
  28461. * Sets an interger value on a uniform variable.
  28462. * @param uniformName Name of the variable.
  28463. * @param value Value to be set.
  28464. * @returns this effect.
  28465. */
  28466. setInt(uniformName: string, value: number): Effect;
  28467. /**
  28468. * Sets an int array on a uniform variable.
  28469. * @param uniformName Name of the variable.
  28470. * @param array array to be set.
  28471. * @returns this effect.
  28472. */
  28473. setIntArray(uniformName: string, array: Int32Array): Effect;
  28474. /**
  28475. * 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)
  28476. * @param uniformName Name of the variable.
  28477. * @param array array to be set.
  28478. * @returns this effect.
  28479. */
  28480. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28481. /**
  28482. * 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)
  28483. * @param uniformName Name of the variable.
  28484. * @param array array to be set.
  28485. * @returns this effect.
  28486. */
  28487. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28488. /**
  28489. * 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)
  28490. * @param uniformName Name of the variable.
  28491. * @param array array to be set.
  28492. * @returns this effect.
  28493. */
  28494. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28495. /**
  28496. * Sets an float array on a uniform variable.
  28497. * @param uniformName Name of the variable.
  28498. * @param array array to be set.
  28499. * @returns this effect.
  28500. */
  28501. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28502. /**
  28503. * 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)
  28504. * @param uniformName Name of the variable.
  28505. * @param array array to be set.
  28506. * @returns this effect.
  28507. */
  28508. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28509. /**
  28510. * 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)
  28511. * @param uniformName Name of the variable.
  28512. * @param array array to be set.
  28513. * @returns this effect.
  28514. */
  28515. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28516. /**
  28517. * 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)
  28518. * @param uniformName Name of the variable.
  28519. * @param array array to be set.
  28520. * @returns this effect.
  28521. */
  28522. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28523. /**
  28524. * Sets an array on a uniform variable.
  28525. * @param uniformName Name of the variable.
  28526. * @param array array to be set.
  28527. * @returns this effect.
  28528. */
  28529. setArray(uniformName: string, array: number[]): Effect;
  28530. /**
  28531. * 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)
  28532. * @param uniformName Name of the variable.
  28533. * @param array array to be set.
  28534. * @returns this effect.
  28535. */
  28536. setArray2(uniformName: string, array: number[]): Effect;
  28537. /**
  28538. * 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)
  28539. * @param uniformName Name of the variable.
  28540. * @param array array to be set.
  28541. * @returns this effect.
  28542. */
  28543. setArray3(uniformName: string, array: number[]): Effect;
  28544. /**
  28545. * 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)
  28546. * @param uniformName Name of the variable.
  28547. * @param array array to be set.
  28548. * @returns this effect.
  28549. */
  28550. setArray4(uniformName: string, array: number[]): Effect;
  28551. /**
  28552. * Sets matrices on a uniform variable.
  28553. * @param uniformName Name of the variable.
  28554. * @param matrices matrices to be set.
  28555. * @returns this effect.
  28556. */
  28557. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28558. /**
  28559. * Sets matrix on a uniform variable.
  28560. * @param uniformName Name of the variable.
  28561. * @param matrix matrix to be set.
  28562. * @returns this effect.
  28563. */
  28564. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  28565. /**
  28566. * 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)
  28567. * @param uniformName Name of the variable.
  28568. * @param matrix matrix to be set.
  28569. * @returns this effect.
  28570. */
  28571. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28572. /**
  28573. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28574. * @param uniformName Name of the variable.
  28575. * @param matrix matrix to be set.
  28576. * @returns this effect.
  28577. */
  28578. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28579. /**
  28580. * Sets a float on a uniform variable.
  28581. * @param uniformName Name of the variable.
  28582. * @param value value to be set.
  28583. * @returns this effect.
  28584. */
  28585. setFloat(uniformName: string, value: number): Effect;
  28586. /**
  28587. * Sets a boolean on a uniform variable.
  28588. * @param uniformName Name of the variable.
  28589. * @param bool value to be set.
  28590. * @returns this effect.
  28591. */
  28592. setBool(uniformName: string, bool: boolean): Effect;
  28593. /**
  28594. * Sets a Vector2 on a uniform variable.
  28595. * @param uniformName Name of the variable.
  28596. * @param vector2 vector2 to be set.
  28597. * @returns this effect.
  28598. */
  28599. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28600. /**
  28601. * Sets a float2 on a uniform variable.
  28602. * @param uniformName Name of the variable.
  28603. * @param x First float in float2.
  28604. * @param y Second float in float2.
  28605. * @returns this effect.
  28606. */
  28607. setFloat2(uniformName: string, x: number, y: number): Effect;
  28608. /**
  28609. * Sets a Vector3 on a uniform variable.
  28610. * @param uniformName Name of the variable.
  28611. * @param vector3 Value to be set.
  28612. * @returns this effect.
  28613. */
  28614. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28615. /**
  28616. * Sets a float3 on a uniform variable.
  28617. * @param uniformName Name of the variable.
  28618. * @param x First float in float3.
  28619. * @param y Second float in float3.
  28620. * @param z Third float in float3.
  28621. * @returns this effect.
  28622. */
  28623. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28624. /**
  28625. * Sets a Vector4 on a uniform variable.
  28626. * @param uniformName Name of the variable.
  28627. * @param vector4 Value to be set.
  28628. * @returns this effect.
  28629. */
  28630. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28631. /**
  28632. * Sets a float4 on a uniform variable.
  28633. * @param uniformName Name of the variable.
  28634. * @param x First float in float4.
  28635. * @param y Second float in float4.
  28636. * @param z Third float in float4.
  28637. * @param w Fourth float in float4.
  28638. * @returns this effect.
  28639. */
  28640. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28641. /**
  28642. * Sets a Color3 on a uniform variable.
  28643. * @param uniformName Name of the variable.
  28644. * @param color3 Value to be set.
  28645. * @returns this effect.
  28646. */
  28647. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28648. /**
  28649. * Sets a Color4 on a uniform variable.
  28650. * @param uniformName Name of the variable.
  28651. * @param color3 Value to be set.
  28652. * @param alpha Alpha value to be set.
  28653. * @returns this effect.
  28654. */
  28655. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28656. /**
  28657. * Sets a Color4 on a uniform variable
  28658. * @param uniformName defines the name of the variable
  28659. * @param color4 defines the value to be set
  28660. * @returns this effect.
  28661. */
  28662. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28663. /** Release all associated resources */
  28664. dispose(): void;
  28665. /**
  28666. * This function will add a new shader to the shader store
  28667. * @param name the name of the shader
  28668. * @param pixelShader optional pixel shader content
  28669. * @param vertexShader optional vertex shader content
  28670. */
  28671. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28672. /**
  28673. * Store of each shader (The can be looked up using effect.key)
  28674. */
  28675. static ShadersStore: {
  28676. [key: string]: string;
  28677. };
  28678. /**
  28679. * Store of each included file for a shader (The can be looked up using effect.key)
  28680. */
  28681. static IncludesShadersStore: {
  28682. [key: string]: string;
  28683. };
  28684. /**
  28685. * Resets the cache of effects.
  28686. */
  28687. static ResetCache(): void;
  28688. }
  28689. }
  28690. declare module BABYLON {
  28691. /**
  28692. * Class used to describe the capabilities of the engine relatively to the current browser
  28693. */
  28694. export class EngineCapabilities {
  28695. /** Maximum textures units per fragment shader */
  28696. maxTexturesImageUnits: number;
  28697. /** Maximum texture units per vertex shader */
  28698. maxVertexTextureImageUnits: number;
  28699. /** Maximum textures units in the entire pipeline */
  28700. maxCombinedTexturesImageUnits: number;
  28701. /** Maximum texture size */
  28702. maxTextureSize: number;
  28703. /** Maximum cube texture size */
  28704. maxCubemapTextureSize: number;
  28705. /** Maximum render texture size */
  28706. maxRenderTextureSize: number;
  28707. /** Maximum number of vertex attributes */
  28708. maxVertexAttribs: number;
  28709. /** Maximum number of varyings */
  28710. maxVaryingVectors: number;
  28711. /** Maximum number of uniforms per vertex shader */
  28712. maxVertexUniformVectors: number;
  28713. /** Maximum number of uniforms per fragment shader */
  28714. maxFragmentUniformVectors: number;
  28715. /** Defines if standard derivates (dx/dy) are supported */
  28716. standardDerivatives: boolean;
  28717. /** Defines if s3tc texture compression is supported */
  28718. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28719. /** Defines if pvrtc texture compression is supported */
  28720. pvrtc: any;
  28721. /** Defines if etc1 texture compression is supported */
  28722. etc1: any;
  28723. /** Defines if etc2 texture compression is supported */
  28724. etc2: any;
  28725. /** Defines if astc texture compression is supported */
  28726. astc: any;
  28727. /** Defines if float textures are supported */
  28728. textureFloat: boolean;
  28729. /** Defines if vertex array objects are supported */
  28730. vertexArrayObject: boolean;
  28731. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28732. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28733. /** Gets the maximum level of anisotropy supported */
  28734. maxAnisotropy: number;
  28735. /** Defines if instancing is supported */
  28736. instancedArrays: boolean;
  28737. /** Defines if 32 bits indices are supported */
  28738. uintIndices: boolean;
  28739. /** Defines if high precision shaders are supported */
  28740. highPrecisionShaderSupported: boolean;
  28741. /** Defines if depth reading in the fragment shader is supported */
  28742. fragmentDepthSupported: boolean;
  28743. /** Defines if float texture linear filtering is supported*/
  28744. textureFloatLinearFiltering: boolean;
  28745. /** Defines if rendering to float textures is supported */
  28746. textureFloatRender: boolean;
  28747. /** Defines if half float textures are supported*/
  28748. textureHalfFloat: boolean;
  28749. /** Defines if half float texture linear filtering is supported*/
  28750. textureHalfFloatLinearFiltering: boolean;
  28751. /** Defines if rendering to half float textures is supported */
  28752. textureHalfFloatRender: boolean;
  28753. /** Defines if textureLOD shader command is supported */
  28754. textureLOD: boolean;
  28755. /** Defines if draw buffers extension is supported */
  28756. drawBuffersExtension: boolean;
  28757. /** Defines if depth textures are supported */
  28758. depthTextureExtension: boolean;
  28759. /** Defines if float color buffer are supported */
  28760. colorBufferFloat: boolean;
  28761. /** Gets disjoint timer query extension (null if not supported) */
  28762. timerQuery: EXT_disjoint_timer_query;
  28763. /** Defines if timestamp can be used with timer query */
  28764. canUseTimestampForTimerQuery: boolean;
  28765. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28766. multiview: any;
  28767. /** Function used to let the system compiles shaders in background */
  28768. parallelShaderCompile: {
  28769. COMPLETION_STATUS_KHR: number;
  28770. };
  28771. /** Max number of texture samples for MSAA */
  28772. maxMSAASamples: number;
  28773. /** Defines if the blend min max extension is supported */
  28774. blendMinMax: boolean;
  28775. }
  28776. }
  28777. declare module BABYLON {
  28778. /**
  28779. * This class is used to track a performance counter which is number based.
  28780. * The user has access to many properties which give statistics of different nature.
  28781. *
  28782. * The implementer can track two kinds of Performance Counter: time and count.
  28783. * 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.
  28784. * 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.
  28785. */
  28786. export class PerfCounter {
  28787. /**
  28788. * Gets or sets a global boolean to turn on and off all the counters
  28789. */
  28790. static Enabled: boolean;
  28791. /**
  28792. * Returns the smallest value ever
  28793. */
  28794. readonly min: number;
  28795. /**
  28796. * Returns the biggest value ever
  28797. */
  28798. readonly max: number;
  28799. /**
  28800. * Returns the average value since the performance counter is running
  28801. */
  28802. readonly average: number;
  28803. /**
  28804. * Returns the average value of the last second the counter was monitored
  28805. */
  28806. readonly lastSecAverage: number;
  28807. /**
  28808. * Returns the current value
  28809. */
  28810. readonly current: number;
  28811. /**
  28812. * Gets the accumulated total
  28813. */
  28814. readonly total: number;
  28815. /**
  28816. * Gets the total value count
  28817. */
  28818. readonly count: number;
  28819. /**
  28820. * Creates a new counter
  28821. */
  28822. constructor();
  28823. /**
  28824. * Call this method to start monitoring a new frame.
  28825. * 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.
  28826. */
  28827. fetchNewFrame(): void;
  28828. /**
  28829. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28830. * @param newCount the count value to add to the monitored count
  28831. * @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.
  28832. */
  28833. addCount(newCount: number, fetchResult: boolean): void;
  28834. /**
  28835. * Start monitoring this performance counter
  28836. */
  28837. beginMonitoring(): void;
  28838. /**
  28839. * Compute the time lapsed since the previous beginMonitoring() call.
  28840. * @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
  28841. */
  28842. endMonitoring(newFrame?: boolean): void;
  28843. private _fetchResult;
  28844. private _startMonitoringTime;
  28845. private _min;
  28846. private _max;
  28847. private _average;
  28848. private _current;
  28849. private _totalValueCount;
  28850. private _totalAccumulated;
  28851. private _lastSecAverage;
  28852. private _lastSecAccumulated;
  28853. private _lastSecTime;
  28854. private _lastSecValueCount;
  28855. }
  28856. }
  28857. declare module BABYLON {
  28858. /**
  28859. * @hidden
  28860. **/
  28861. export class DepthCullingState {
  28862. private _isDepthTestDirty;
  28863. private _isDepthMaskDirty;
  28864. private _isDepthFuncDirty;
  28865. private _isCullFaceDirty;
  28866. private _isCullDirty;
  28867. private _isZOffsetDirty;
  28868. private _isFrontFaceDirty;
  28869. private _depthTest;
  28870. private _depthMask;
  28871. private _depthFunc;
  28872. private _cull;
  28873. private _cullFace;
  28874. private _zOffset;
  28875. private _frontFace;
  28876. /**
  28877. * Initializes the state.
  28878. */
  28879. constructor();
  28880. readonly isDirty: boolean;
  28881. zOffset: number;
  28882. cullFace: Nullable<number>;
  28883. cull: Nullable<boolean>;
  28884. depthFunc: Nullable<number>;
  28885. depthMask: boolean;
  28886. depthTest: boolean;
  28887. frontFace: Nullable<number>;
  28888. reset(): void;
  28889. apply(gl: WebGLRenderingContext): void;
  28890. }
  28891. }
  28892. declare module BABYLON {
  28893. /**
  28894. * @hidden
  28895. **/
  28896. export class StencilState {
  28897. /** 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 */
  28898. static readonly ALWAYS: number;
  28899. /** Passed to stencilOperation to specify that stencil value must be kept */
  28900. static readonly KEEP: number;
  28901. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28902. static readonly REPLACE: number;
  28903. private _isStencilTestDirty;
  28904. private _isStencilMaskDirty;
  28905. private _isStencilFuncDirty;
  28906. private _isStencilOpDirty;
  28907. private _stencilTest;
  28908. private _stencilMask;
  28909. private _stencilFunc;
  28910. private _stencilFuncRef;
  28911. private _stencilFuncMask;
  28912. private _stencilOpStencilFail;
  28913. private _stencilOpDepthFail;
  28914. private _stencilOpStencilDepthPass;
  28915. readonly isDirty: boolean;
  28916. stencilFunc: number;
  28917. stencilFuncRef: number;
  28918. stencilFuncMask: number;
  28919. stencilOpStencilFail: number;
  28920. stencilOpDepthFail: number;
  28921. stencilOpStencilDepthPass: number;
  28922. stencilMask: number;
  28923. stencilTest: boolean;
  28924. constructor();
  28925. reset(): void;
  28926. apply(gl: WebGLRenderingContext): void;
  28927. }
  28928. }
  28929. declare module BABYLON {
  28930. /**
  28931. * @hidden
  28932. **/
  28933. export class AlphaState {
  28934. private _isAlphaBlendDirty;
  28935. private _isBlendFunctionParametersDirty;
  28936. private _isBlendEquationParametersDirty;
  28937. private _isBlendConstantsDirty;
  28938. private _alphaBlend;
  28939. private _blendFunctionParameters;
  28940. private _blendEquationParameters;
  28941. private _blendConstants;
  28942. /**
  28943. * Initializes the state.
  28944. */
  28945. constructor();
  28946. readonly isDirty: boolean;
  28947. alphaBlend: boolean;
  28948. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28949. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28950. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28951. reset(): void;
  28952. apply(gl: WebGLRenderingContext): void;
  28953. }
  28954. }
  28955. declare module BABYLON {
  28956. /** @hidden */
  28957. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28958. attributeProcessor(attribute: string): string;
  28959. varyingProcessor(varying: string, isFragment: boolean): string;
  28960. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28961. }
  28962. }
  28963. declare module BABYLON {
  28964. /**
  28965. * Interface for attribute information associated with buffer instanciation
  28966. */
  28967. export class InstancingAttributeInfo {
  28968. /**
  28969. * Index/offset of the attribute in the vertex shader
  28970. */
  28971. index: number;
  28972. /**
  28973. * size of the attribute, 1, 2, 3 or 4
  28974. */
  28975. attributeSize: number;
  28976. /**
  28977. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28978. * default is FLOAT
  28979. */
  28980. attribyteType: number;
  28981. /**
  28982. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28983. */
  28984. normalized: boolean;
  28985. /**
  28986. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28987. */
  28988. offset: number;
  28989. /**
  28990. * Name of the GLSL attribute, for debugging purpose only
  28991. */
  28992. attributeName: string;
  28993. }
  28994. }
  28995. declare module BABYLON {
  28996. interface ThinEngine {
  28997. /**
  28998. * Update a video texture
  28999. * @param texture defines the texture to update
  29000. * @param video defines the video element to use
  29001. * @param invertY defines if data must be stored with Y axis inverted
  29002. */
  29003. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29004. }
  29005. }
  29006. declare module BABYLON {
  29007. /**
  29008. * Settings for finer control over video usage
  29009. */
  29010. export interface VideoTextureSettings {
  29011. /**
  29012. * Applies `autoplay` to video, if specified
  29013. */
  29014. autoPlay?: boolean;
  29015. /**
  29016. * Applies `loop` to video, if specified
  29017. */
  29018. loop?: boolean;
  29019. /**
  29020. * Automatically updates internal texture from video at every frame in the render loop
  29021. */
  29022. autoUpdateTexture: boolean;
  29023. /**
  29024. * Image src displayed during the video loading or until the user interacts with the video.
  29025. */
  29026. poster?: string;
  29027. }
  29028. /**
  29029. * If you want to display a video in your scene, this is the special texture for that.
  29030. * This special texture works similar to other textures, with the exception of a few parameters.
  29031. * @see https://doc.babylonjs.com/how_to/video_texture
  29032. */
  29033. export class VideoTexture extends Texture {
  29034. /**
  29035. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29036. */
  29037. readonly autoUpdateTexture: boolean;
  29038. /**
  29039. * The video instance used by the texture internally
  29040. */
  29041. readonly video: HTMLVideoElement;
  29042. private _onUserActionRequestedObservable;
  29043. /**
  29044. * Event triggerd when a dom action is required by the user to play the video.
  29045. * This happens due to recent changes in browser policies preventing video to auto start.
  29046. */
  29047. readonly onUserActionRequestedObservable: Observable<Texture>;
  29048. private _generateMipMaps;
  29049. private _engine;
  29050. private _stillImageCaptured;
  29051. private _displayingPosterTexture;
  29052. private _settings;
  29053. private _createInternalTextureOnEvent;
  29054. private _frameId;
  29055. /**
  29056. * Creates a video texture.
  29057. * If you want to display a video in your scene, this is the special texture for that.
  29058. * This special texture works similar to other textures, with the exception of a few parameters.
  29059. * @see https://doc.babylonjs.com/how_to/video_texture
  29060. * @param name optional name, will detect from video source, if not defined
  29061. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29062. * @param scene is obviously the current scene.
  29063. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29064. * @param invertY is false by default but can be used to invert video on Y axis
  29065. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29066. * @param settings allows finer control over video usage
  29067. */
  29068. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29069. private _getName;
  29070. private _getVideo;
  29071. private _createInternalTexture;
  29072. private reset;
  29073. /**
  29074. * @hidden Internal method to initiate `update`.
  29075. */
  29076. _rebuild(): void;
  29077. /**
  29078. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29079. */
  29080. update(): void;
  29081. /**
  29082. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29083. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29084. */
  29085. updateTexture(isVisible: boolean): void;
  29086. protected _updateInternalTexture: () => void;
  29087. /**
  29088. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29089. * @param url New url.
  29090. */
  29091. updateURL(url: string): void;
  29092. /**
  29093. * Dispose the texture and release its associated resources.
  29094. */
  29095. dispose(): void;
  29096. /**
  29097. * Creates a video texture straight from a stream.
  29098. * @param scene Define the scene the texture should be created in
  29099. * @param stream Define the stream the texture should be created from
  29100. * @returns The created video texture as a promise
  29101. */
  29102. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29103. /**
  29104. * Creates a video texture straight from your WebCam video feed.
  29105. * @param scene Define the scene the texture should be created in
  29106. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29107. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29108. * @returns The created video texture as a promise
  29109. */
  29110. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29111. minWidth: number;
  29112. maxWidth: number;
  29113. minHeight: number;
  29114. maxHeight: number;
  29115. deviceId: string;
  29116. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29117. /**
  29118. * Creates a video texture straight from your WebCam video feed.
  29119. * @param scene Define the scene the texture should be created in
  29120. * @param onReady Define a callback to triggered once the texture will be ready
  29121. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29122. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29123. */
  29124. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29125. minWidth: number;
  29126. maxWidth: number;
  29127. minHeight: number;
  29128. maxHeight: number;
  29129. deviceId: string;
  29130. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29131. }
  29132. }
  29133. declare module BABYLON {
  29134. /**
  29135. * Defines the interface used by objects working like Scene
  29136. * @hidden
  29137. */
  29138. interface ISceneLike {
  29139. _addPendingData(data: any): void;
  29140. _removePendingData(data: any): void;
  29141. offlineProvider: IOfflineProvider;
  29142. }
  29143. /** Interface defining initialization parameters for Engine class */
  29144. export interface EngineOptions extends WebGLContextAttributes {
  29145. /**
  29146. * Defines if the engine should no exceed a specified device ratio
  29147. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29148. */
  29149. limitDeviceRatio?: number;
  29150. /**
  29151. * Defines if webvr should be enabled automatically
  29152. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29153. */
  29154. autoEnableWebVR?: boolean;
  29155. /**
  29156. * Defines if webgl2 should be turned off even if supported
  29157. * @see http://doc.babylonjs.com/features/webgl2
  29158. */
  29159. disableWebGL2Support?: boolean;
  29160. /**
  29161. * Defines if webaudio should be initialized as well
  29162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29163. */
  29164. audioEngine?: boolean;
  29165. /**
  29166. * Defines if animations should run using a deterministic lock step
  29167. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29168. */
  29169. deterministicLockstep?: boolean;
  29170. /** Defines the maximum steps to use with deterministic lock step mode */
  29171. lockstepMaxSteps?: number;
  29172. /**
  29173. * Defines that engine should ignore context lost events
  29174. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29175. */
  29176. doNotHandleContextLost?: boolean;
  29177. /**
  29178. * Defines that engine should ignore modifying touch action attribute and style
  29179. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29180. */
  29181. doNotHandleTouchAction?: boolean;
  29182. /**
  29183. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29184. */
  29185. useHighPrecisionFloats?: boolean;
  29186. }
  29187. /**
  29188. * The base engine class (root of all engines)
  29189. */
  29190. export class ThinEngine {
  29191. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29192. static ExceptionList: ({
  29193. key: string;
  29194. capture: string;
  29195. captureConstraint: number;
  29196. targets: string[];
  29197. } | {
  29198. key: string;
  29199. capture: null;
  29200. captureConstraint: null;
  29201. targets: string[];
  29202. })[];
  29203. /** @hidden */
  29204. static _TextureLoaders: IInternalTextureLoader[];
  29205. /**
  29206. * Returns the current npm package of the sdk
  29207. */
  29208. static readonly NpmPackage: string;
  29209. /**
  29210. * Returns the current version of the framework
  29211. */
  29212. static readonly Version: string;
  29213. /**
  29214. * Returns a string describing the current engine
  29215. */
  29216. readonly description: string;
  29217. /**
  29218. * Gets or sets the epsilon value used by collision engine
  29219. */
  29220. static CollisionsEpsilon: number;
  29221. /**
  29222. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29223. */
  29224. static ShadersRepository: string;
  29225. /** @hidden */
  29226. _shaderProcessor: IShaderProcessor;
  29227. /**
  29228. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29229. */
  29230. forcePOTTextures: boolean;
  29231. /**
  29232. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29233. */
  29234. isFullscreen: boolean;
  29235. /**
  29236. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29237. */
  29238. cullBackFaces: boolean;
  29239. /**
  29240. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29241. */
  29242. renderEvenInBackground: boolean;
  29243. /**
  29244. * Gets or sets a boolean indicating that cache can be kept between frames
  29245. */
  29246. preventCacheWipeBetweenFrames: boolean;
  29247. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29248. validateShaderPrograms: boolean;
  29249. /**
  29250. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29251. */
  29252. disableUniformBuffers: boolean;
  29253. /** @hidden */
  29254. _uniformBuffers: UniformBuffer[];
  29255. /**
  29256. * Gets a boolean indicating that the engine supports uniform buffers
  29257. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29258. */
  29259. readonly supportsUniformBuffers: boolean;
  29260. /** @hidden */
  29261. _gl: WebGLRenderingContext;
  29262. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29263. protected _windowIsBackground: boolean;
  29264. protected _webGLVersion: number;
  29265. protected _highPrecisionShadersAllowed: boolean;
  29266. /** @hidden */
  29267. readonly _shouldUseHighPrecisionShader: boolean;
  29268. /**
  29269. * Gets a boolean indicating that only power of 2 textures are supported
  29270. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29271. */
  29272. readonly needPOTTextures: boolean;
  29273. /** @hidden */
  29274. _badOS: boolean;
  29275. /** @hidden */
  29276. _badDesktopOS: boolean;
  29277. private _hardwareScalingLevel;
  29278. /** @hidden */
  29279. _caps: EngineCapabilities;
  29280. private _isStencilEnable;
  29281. protected _colorWrite: boolean;
  29282. /** @hidden */
  29283. _drawCalls: PerfCounter;
  29284. private _glVersion;
  29285. private _glRenderer;
  29286. private _glVendor;
  29287. /** @hidden */
  29288. _videoTextureSupported: boolean;
  29289. protected _renderingQueueLaunched: boolean;
  29290. protected _activeRenderLoops: (() => void)[];
  29291. /**
  29292. * Observable signaled when a context lost event is raised
  29293. */
  29294. onContextLostObservable: Observable<ThinEngine>;
  29295. /**
  29296. * Observable signaled when a context restored event is raised
  29297. */
  29298. onContextRestoredObservable: Observable<ThinEngine>;
  29299. private _onContextLost;
  29300. private _onContextRestored;
  29301. protected _contextWasLost: boolean;
  29302. /** @hidden */
  29303. _doNotHandleContextLost: boolean;
  29304. /**
  29305. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29307. */
  29308. doNotHandleContextLost: boolean;
  29309. /**
  29310. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29311. */
  29312. disableVertexArrayObjects: boolean;
  29313. /** @hidden */
  29314. protected _depthCullingState: DepthCullingState;
  29315. /** @hidden */
  29316. protected _stencilState: StencilState;
  29317. /** @hidden */
  29318. protected _alphaState: AlphaState;
  29319. /** @hidden */
  29320. _internalTexturesCache: InternalTexture[];
  29321. /** @hidden */
  29322. protected _activeChannel: number;
  29323. private _currentTextureChannel;
  29324. /** @hidden */
  29325. protected _boundTexturesCache: {
  29326. [key: string]: Nullable<InternalTexture>;
  29327. };
  29328. /** @hidden */
  29329. protected _currentEffect: Nullable<Effect>;
  29330. /** @hidden */
  29331. protected _currentProgram: Nullable<WebGLProgram>;
  29332. private _compiledEffects;
  29333. private _vertexAttribArraysEnabled;
  29334. /** @hidden */
  29335. protected _cachedViewport: Nullable<IViewportLike>;
  29336. private _cachedVertexArrayObject;
  29337. /** @hidden */
  29338. protected _cachedVertexBuffers: any;
  29339. /** @hidden */
  29340. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29341. /** @hidden */
  29342. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29343. /** @hidden */
  29344. _currentRenderTarget: Nullable<InternalTexture>;
  29345. private _uintIndicesCurrentlySet;
  29346. private _currentBoundBuffer;
  29347. /** @hidden */
  29348. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29349. private _currentBufferPointers;
  29350. private _currentInstanceLocations;
  29351. private _currentInstanceBuffers;
  29352. private _textureUnits;
  29353. /** @hidden */
  29354. _workingCanvas: Nullable<HTMLCanvasElement>;
  29355. /** @hidden */
  29356. _workingContext: Nullable<CanvasRenderingContext2D>;
  29357. /** @hidden */
  29358. _bindedRenderFunction: any;
  29359. private _vaoRecordInProgress;
  29360. private _mustWipeVertexAttributes;
  29361. private _emptyTexture;
  29362. private _emptyCubeTexture;
  29363. private _emptyTexture3D;
  29364. /** @hidden */
  29365. _frameHandler: number;
  29366. private _nextFreeTextureSlots;
  29367. private _maxSimultaneousTextures;
  29368. private _activeRequests;
  29369. protected _texturesSupported: string[];
  29370. /** @hidden */
  29371. _textureFormatInUse: Nullable<string>;
  29372. protected readonly _supportsHardwareTextureRescaling: boolean;
  29373. /**
  29374. * Gets the list of texture formats supported
  29375. */
  29376. readonly texturesSupported: Array<string>;
  29377. /**
  29378. * Gets the list of texture formats in use
  29379. */
  29380. readonly textureFormatInUse: Nullable<string>;
  29381. /**
  29382. * Gets the current viewport
  29383. */
  29384. readonly currentViewport: Nullable<IViewportLike>;
  29385. /**
  29386. * Gets the default empty texture
  29387. */
  29388. readonly emptyTexture: InternalTexture;
  29389. /**
  29390. * Gets the default empty 3D texture
  29391. */
  29392. readonly emptyTexture3D: InternalTexture;
  29393. /**
  29394. * Gets the default empty cube texture
  29395. */
  29396. readonly emptyCubeTexture: InternalTexture;
  29397. /**
  29398. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29399. */
  29400. readonly premultipliedAlpha: boolean;
  29401. /**
  29402. * Creates a new engine
  29403. * @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
  29404. * @param antialias defines enable antialiasing (default: false)
  29405. * @param options defines further options to be sent to the getContext() function
  29406. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29407. */
  29408. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29409. private _rebuildInternalTextures;
  29410. private _rebuildEffects;
  29411. /**
  29412. * Gets a boolean indicating if all created effects are ready
  29413. * @returns true if all effects are ready
  29414. */
  29415. areAllEffectsReady(): boolean;
  29416. protected _rebuildBuffers(): void;
  29417. private _initGLContext;
  29418. /**
  29419. * Gets version of the current webGL context
  29420. */
  29421. readonly webGLVersion: number;
  29422. /**
  29423. * Gets a string idenfifying the name of the class
  29424. * @returns "Engine" string
  29425. */
  29426. getClassName(): string;
  29427. /**
  29428. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29429. */
  29430. readonly isStencilEnable: boolean;
  29431. /** @hidden */
  29432. _prepareWorkingCanvas(): void;
  29433. /**
  29434. * Reset the texture cache to empty state
  29435. */
  29436. resetTextureCache(): void;
  29437. /**
  29438. * Gets an object containing information about the current webGL context
  29439. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29440. */
  29441. getGlInfo(): {
  29442. vendor: string;
  29443. renderer: string;
  29444. version: string;
  29445. };
  29446. /**
  29447. * Defines the hardware scaling level.
  29448. * By default the hardware scaling level is computed from the window device ratio.
  29449. * 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.
  29450. * @param level defines the level to use
  29451. */
  29452. setHardwareScalingLevel(level: number): void;
  29453. /**
  29454. * Gets the current hardware scaling level.
  29455. * By default the hardware scaling level is computed from the window device ratio.
  29456. * 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.
  29457. * @returns a number indicating the current hardware scaling level
  29458. */
  29459. getHardwareScalingLevel(): number;
  29460. /**
  29461. * Gets the list of loaded textures
  29462. * @returns an array containing all loaded textures
  29463. */
  29464. getLoadedTexturesCache(): InternalTexture[];
  29465. /**
  29466. * Gets the object containing all engine capabilities
  29467. * @returns the EngineCapabilities object
  29468. */
  29469. getCaps(): EngineCapabilities;
  29470. /**
  29471. * stop executing a render loop function and remove it from the execution array
  29472. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29473. */
  29474. stopRenderLoop(renderFunction?: () => void): void;
  29475. /** @hidden */
  29476. _renderLoop(): void;
  29477. /**
  29478. * Gets the HTML canvas attached with the current webGL context
  29479. * @returns a HTML canvas
  29480. */
  29481. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29482. /**
  29483. * Gets host window
  29484. * @returns the host window object
  29485. */
  29486. getHostWindow(): Window;
  29487. /**
  29488. * Gets the current render width
  29489. * @param useScreen defines if screen size must be used (or the current render target if any)
  29490. * @returns a number defining the current render width
  29491. */
  29492. getRenderWidth(useScreen?: boolean): number;
  29493. /**
  29494. * Gets the current render height
  29495. * @param useScreen defines if screen size must be used (or the current render target if any)
  29496. * @returns a number defining the current render height
  29497. */
  29498. getRenderHeight(useScreen?: boolean): number;
  29499. /**
  29500. * Can be used to override the current requestAnimationFrame requester.
  29501. * @hidden
  29502. */
  29503. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  29504. /**
  29505. * Register and execute a render loop. The engine can have more than one render function
  29506. * @param renderFunction defines the function to continuously execute
  29507. */
  29508. runRenderLoop(renderFunction: () => void): void;
  29509. /**
  29510. * Clear the current render buffer or the current render target (if any is set up)
  29511. * @param color defines the color to use
  29512. * @param backBuffer defines if the back buffer must be cleared
  29513. * @param depth defines if the depth buffer must be cleared
  29514. * @param stencil defines if the stencil buffer must be cleared
  29515. */
  29516. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29517. private _viewportCached;
  29518. /** @hidden */
  29519. _viewport(x: number, y: number, width: number, height: number): void;
  29520. /**
  29521. * Set the WebGL's viewport
  29522. * @param viewport defines the viewport element to be used
  29523. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29524. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29525. */
  29526. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  29527. /**
  29528. * Begin a new frame
  29529. */
  29530. beginFrame(): void;
  29531. /**
  29532. * Enf the current frame
  29533. */
  29534. endFrame(): void;
  29535. /**
  29536. * Resize the view according to the canvas' size
  29537. */
  29538. resize(): void;
  29539. /**
  29540. * Force a specific size of the canvas
  29541. * @param width defines the new canvas' width
  29542. * @param height defines the new canvas' height
  29543. */
  29544. setSize(width: number, height: number): void;
  29545. /**
  29546. * Binds the frame buffer to the specified texture.
  29547. * @param texture The texture to render to or null for the default canvas
  29548. * @param faceIndex The face of the texture to render to in case of cube texture
  29549. * @param requiredWidth The width of the target to render to
  29550. * @param requiredHeight The height of the target to render to
  29551. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29552. * @param depthStencilTexture The depth stencil texture to use to render
  29553. * @param lodLevel defines le lod level to bind to the frame buffer
  29554. */
  29555. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29556. /** @hidden */
  29557. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29558. /**
  29559. * Unbind the current render target texture from the webGL context
  29560. * @param texture defines the render target texture to unbind
  29561. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29562. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29563. */
  29564. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29565. /**
  29566. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29567. */
  29568. flushFramebuffer(): void;
  29569. /**
  29570. * Unbind the current render target and bind the default framebuffer
  29571. */
  29572. restoreDefaultFramebuffer(): void;
  29573. private _resetVertexBufferBinding;
  29574. /**
  29575. * Creates a vertex buffer
  29576. * @param data the data for the vertex buffer
  29577. * @returns the new WebGL static buffer
  29578. */
  29579. createVertexBuffer(data: DataArray): DataBuffer;
  29580. private _createVertexBuffer;
  29581. /**
  29582. * Creates a dynamic vertex buffer
  29583. * @param data the data for the dynamic vertex buffer
  29584. * @returns the new WebGL dynamic buffer
  29585. */
  29586. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29587. /**
  29588. * Update a dynamic index buffer
  29589. * @param indexBuffer defines the target index buffer
  29590. * @param indices defines the data to update
  29591. * @param offset defines the offset in the target index buffer where update should start
  29592. */
  29593. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29594. /**
  29595. * Updates a dynamic vertex buffer.
  29596. * @param vertexBuffer the vertex buffer to update
  29597. * @param data the data used to update the vertex buffer
  29598. * @param byteOffset the byte offset of the data
  29599. * @param byteLength the byte length of the data
  29600. */
  29601. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29602. private _resetIndexBufferBinding;
  29603. /**
  29604. * Creates a new index buffer
  29605. * @param indices defines the content of the index buffer
  29606. * @param updatable defines if the index buffer must be updatable
  29607. * @returns a new webGL buffer
  29608. */
  29609. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29610. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  29611. /**
  29612. * Bind a webGL buffer to the webGL context
  29613. * @param buffer defines the buffer to bind
  29614. */
  29615. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29616. private bindIndexBuffer;
  29617. private bindBuffer;
  29618. /**
  29619. * update the bound buffer with the given data
  29620. * @param data defines the data to update
  29621. */
  29622. updateArrayBuffer(data: Float32Array): void;
  29623. private _vertexAttribPointer;
  29624. private _bindIndexBufferWithCache;
  29625. private _bindVertexBuffersAttributes;
  29626. /**
  29627. * Records a vertex array object
  29628. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29629. * @param vertexBuffers defines the list of vertex buffers to store
  29630. * @param indexBuffer defines the index buffer to store
  29631. * @param effect defines the effect to store
  29632. * @returns the new vertex array object
  29633. */
  29634. recordVertexArrayObject(vertexBuffers: {
  29635. [key: string]: VertexBuffer;
  29636. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29637. /**
  29638. * Bind a specific vertex array object
  29639. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29640. * @param vertexArrayObject defines the vertex array object to bind
  29641. * @param indexBuffer defines the index buffer to bind
  29642. */
  29643. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29644. /**
  29645. * Bind webGl buffers directly to the webGL context
  29646. * @param vertexBuffer defines the vertex buffer to bind
  29647. * @param indexBuffer defines the index buffer to bind
  29648. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29649. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29650. * @param effect defines the effect associated with the vertex buffer
  29651. */
  29652. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29653. private _unbindVertexArrayObject;
  29654. /**
  29655. * Bind a list of vertex buffers to the webGL context
  29656. * @param vertexBuffers defines the list of vertex buffers to bind
  29657. * @param indexBuffer defines the index buffer to bind
  29658. * @param effect defines the effect associated with the vertex buffers
  29659. */
  29660. bindBuffers(vertexBuffers: {
  29661. [key: string]: Nullable<VertexBuffer>;
  29662. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29663. /**
  29664. * Unbind all instance attributes
  29665. */
  29666. unbindInstanceAttributes(): void;
  29667. /**
  29668. * Release and free the memory of a vertex array object
  29669. * @param vao defines the vertex array object to delete
  29670. */
  29671. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29672. /** @hidden */
  29673. _releaseBuffer(buffer: DataBuffer): boolean;
  29674. protected _deleteBuffer(buffer: DataBuffer): void;
  29675. /**
  29676. * Creates a webGL buffer to use with instanciation
  29677. * @param capacity defines the size of the buffer
  29678. * @returns the webGL buffer
  29679. */
  29680. createInstancesBuffer(capacity: number): DataBuffer;
  29681. /**
  29682. * Delete a webGL buffer used with instanciation
  29683. * @param buffer defines the webGL buffer to delete
  29684. */
  29685. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29686. /**
  29687. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29688. * @param instancesBuffer defines the webGL buffer to update and bind
  29689. * @param data defines the data to store in the buffer
  29690. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29691. */
  29692. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29693. /**
  29694. * Apply all cached states (depth, culling, stencil and alpha)
  29695. */
  29696. applyStates(): void;
  29697. /**
  29698. * Send a draw order
  29699. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29700. * @param indexStart defines the starting index
  29701. * @param indexCount defines the number of index to draw
  29702. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29703. */
  29704. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29705. /**
  29706. * Draw a list of points
  29707. * @param verticesStart defines the index of first vertex to draw
  29708. * @param verticesCount defines the count of vertices to draw
  29709. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29710. */
  29711. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29712. /**
  29713. * Draw a list of unindexed primitives
  29714. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29715. * @param verticesStart defines the index of first vertex to draw
  29716. * @param verticesCount defines the count of vertices to draw
  29717. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29718. */
  29719. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29720. /**
  29721. * Draw a list of indexed primitives
  29722. * @param fillMode defines the primitive to use
  29723. * @param indexStart defines the starting index
  29724. * @param indexCount defines the number of index to draw
  29725. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29726. */
  29727. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29728. /**
  29729. * Draw a list of unindexed primitives
  29730. * @param fillMode defines the primitive to use
  29731. * @param verticesStart defines the index of first vertex to draw
  29732. * @param verticesCount defines the count of vertices to draw
  29733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29734. */
  29735. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29736. private _drawMode;
  29737. /** @hidden */
  29738. _releaseEffect(effect: Effect): void;
  29739. /** @hidden */
  29740. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29741. /**
  29742. * Create a new effect (used to store vertex/fragment shaders)
  29743. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29744. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29745. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29746. * @param samplers defines an array of string used to represent textures
  29747. * @param defines defines the string containing the defines to use to compile the shaders
  29748. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29749. * @param onCompiled defines a function to call when the effect creation is successful
  29750. * @param onError defines a function to call when the effect creation has failed
  29751. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29752. * @returns the new Effect
  29753. */
  29754. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29755. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  29756. private _compileShader;
  29757. private _compileRawShader;
  29758. /**
  29759. * Directly creates a webGL program
  29760. * @param pipelineContext defines the pipeline context to attach to
  29761. * @param vertexCode defines the vertex shader code to use
  29762. * @param fragmentCode defines the fragment shader code to use
  29763. * @param context defines the webGL context to use (if not set, the current one will be used)
  29764. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29765. * @returns the new webGL program
  29766. */
  29767. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29768. /**
  29769. * Creates a webGL program
  29770. * @param pipelineContext defines the pipeline context to attach to
  29771. * @param vertexCode defines the vertex shader code to use
  29772. * @param fragmentCode defines the fragment shader code to use
  29773. * @param defines defines the string containing the defines to use to compile the shaders
  29774. * @param context defines the webGL context to use (if not set, the current one will be used)
  29775. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29776. * @returns the new webGL program
  29777. */
  29778. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29779. /**
  29780. * Creates a new pipeline context
  29781. * @returns the new pipeline
  29782. */
  29783. createPipelineContext(): IPipelineContext;
  29784. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29785. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  29786. /** @hidden */
  29787. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29788. /** @hidden */
  29789. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29790. /** @hidden */
  29791. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29792. /**
  29793. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29794. * @param pipelineContext defines the pipeline context to use
  29795. * @param uniformsNames defines the list of uniform names
  29796. * @returns an array of webGL uniform locations
  29797. */
  29798. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29799. /**
  29800. * Gets the lsit of active attributes for a given webGL program
  29801. * @param pipelineContext defines the pipeline context to use
  29802. * @param attributesNames defines the list of attribute names to get
  29803. * @returns an array of indices indicating the offset of each attribute
  29804. */
  29805. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29806. /**
  29807. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29808. * @param effect defines the effect to activate
  29809. */
  29810. enableEffect(effect: Nullable<Effect>): void;
  29811. /**
  29812. * Set the value of an uniform to an array of int32
  29813. * @param uniform defines the webGL uniform location where to store the value
  29814. * @param array defines the array of int32 to store
  29815. */
  29816. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29817. /**
  29818. * Set the value of an uniform to an array of int32 (stored as vec2)
  29819. * @param uniform defines the webGL uniform location where to store the value
  29820. * @param array defines the array of int32 to store
  29821. */
  29822. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29823. /**
  29824. * Set the value of an uniform to an array of int32 (stored as vec3)
  29825. * @param uniform defines the webGL uniform location where to store the value
  29826. * @param array defines the array of int32 to store
  29827. */
  29828. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29829. /**
  29830. * Set the value of an uniform to an array of int32 (stored as vec4)
  29831. * @param uniform defines the webGL uniform location where to store the value
  29832. * @param array defines the array of int32 to store
  29833. */
  29834. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29835. /**
  29836. * Set the value of an uniform to an array of float32
  29837. * @param uniform defines the webGL uniform location where to store the value
  29838. * @param array defines the array of float32 to store
  29839. */
  29840. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29841. /**
  29842. * Set the value of an uniform to an array of float32 (stored as vec2)
  29843. * @param uniform defines the webGL uniform location where to store the value
  29844. * @param array defines the array of float32 to store
  29845. */
  29846. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29847. /**
  29848. * Set the value of an uniform to an array of float32 (stored as vec3)
  29849. * @param uniform defines the webGL uniform location where to store the value
  29850. * @param array defines the array of float32 to store
  29851. */
  29852. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29853. /**
  29854. * Set the value of an uniform to an array of float32 (stored as vec4)
  29855. * @param uniform defines the webGL uniform location where to store the value
  29856. * @param array defines the array of float32 to store
  29857. */
  29858. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29859. /**
  29860. * Set the value of an uniform to an array of number
  29861. * @param uniform defines the webGL uniform location where to store the value
  29862. * @param array defines the array of number to store
  29863. */
  29864. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29865. /**
  29866. * Set the value of an uniform to an array of number (stored as vec2)
  29867. * @param uniform defines the webGL uniform location where to store the value
  29868. * @param array defines the array of number to store
  29869. */
  29870. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29871. /**
  29872. * Set the value of an uniform to an array of number (stored as vec3)
  29873. * @param uniform defines the webGL uniform location where to store the value
  29874. * @param array defines the array of number to store
  29875. */
  29876. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29877. /**
  29878. * Set the value of an uniform to an array of number (stored as vec4)
  29879. * @param uniform defines the webGL uniform location where to store the value
  29880. * @param array defines the array of number to store
  29881. */
  29882. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29883. /**
  29884. * Set the value of an uniform to an array of float32 (stored as matrices)
  29885. * @param uniform defines the webGL uniform location where to store the value
  29886. * @param matrices defines the array of float32 to store
  29887. */
  29888. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29889. /**
  29890. * Set the value of an uniform to a matrix (3x3)
  29891. * @param uniform defines the webGL uniform location where to store the value
  29892. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29893. */
  29894. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29895. /**
  29896. * Set the value of an uniform to a matrix (2x2)
  29897. * @param uniform defines the webGL uniform location where to store the value
  29898. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29899. */
  29900. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29901. /**
  29902. * Set the value of an uniform to a number (int)
  29903. * @param uniform defines the webGL uniform location where to store the value
  29904. * @param value defines the int number to store
  29905. */
  29906. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29907. /**
  29908. * Set the value of an uniform to a number (float)
  29909. * @param uniform defines the webGL uniform location where to store the value
  29910. * @param value defines the float number to store
  29911. */
  29912. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29913. /**
  29914. * Set the value of an uniform to a vec2
  29915. * @param uniform defines the webGL uniform location where to store the value
  29916. * @param x defines the 1st component of the value
  29917. * @param y defines the 2nd component of the value
  29918. */
  29919. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29920. /**
  29921. * Set the value of an uniform to a vec3
  29922. * @param uniform defines the webGL uniform location where to store the value
  29923. * @param x defines the 1st component of the value
  29924. * @param y defines the 2nd component of the value
  29925. * @param z defines the 3rd component of the value
  29926. */
  29927. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29928. /**
  29929. * Set the value of an uniform to a boolean
  29930. * @param uniform defines the webGL uniform location where to store the value
  29931. * @param bool defines the boolean to store
  29932. */
  29933. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29934. /**
  29935. * Set the value of an uniform to a vec4
  29936. * @param uniform defines the webGL uniform location where to store the value
  29937. * @param x defines the 1st component of the value
  29938. * @param y defines the 2nd component of the value
  29939. * @param z defines the 3rd component of the value
  29940. * @param w defines the 4th component of the value
  29941. */
  29942. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29943. /**
  29944. * Sets a Color4 on a uniform variable
  29945. * @param uniform defines the uniform location
  29946. * @param color4 defines the value to be set
  29947. */
  29948. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29949. /**
  29950. * Gets the depth culling state manager
  29951. */
  29952. readonly depthCullingState: DepthCullingState;
  29953. /**
  29954. * Gets the alpha state manager
  29955. */
  29956. readonly alphaState: AlphaState;
  29957. /**
  29958. * Gets the stencil state manager
  29959. */
  29960. readonly stencilState: StencilState;
  29961. /**
  29962. * Clears the list of texture accessible through engine.
  29963. * This can help preventing texture load conflict due to name collision.
  29964. */
  29965. clearInternalTexturesCache(): void;
  29966. /**
  29967. * Force the entire cache to be cleared
  29968. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29969. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29970. */
  29971. wipeCaches(bruteForce?: boolean): void;
  29972. /** @hidden */
  29973. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29974. min: number;
  29975. mag: number;
  29976. };
  29977. /** @hidden */
  29978. _createTexture(): WebGLTexture;
  29979. /**
  29980. * Usually called from Texture.ts.
  29981. * Passed information to create a WebGLTexture
  29982. * @param urlArg defines a value which contains one of the following:
  29983. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29984. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29985. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29986. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29987. * @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)
  29988. * @param scene needed for loading to the correct scene
  29989. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29990. * @param onLoad optional callback to be called upon successful completion
  29991. * @param onError optional callback to be called upon failure
  29992. * @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
  29993. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29994. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29995. * @param forcedExtension defines the extension to use to pick the right loader
  29996. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29997. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29998. */
  29999. 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;
  30000. /**
  30001. * @hidden
  30002. */
  30003. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30004. /**
  30005. * Creates a raw texture
  30006. * @param data defines the data to store in the texture
  30007. * @param width defines the width of the texture
  30008. * @param height defines the height of the texture
  30009. * @param format defines the format of the data
  30010. * @param generateMipMaps defines if the engine should generate the mip levels
  30011. * @param invertY defines if data must be stored with Y axis inverted
  30012. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30013. * @param compression defines the compression used (null by default)
  30014. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30015. * @returns the raw texture inside an InternalTexture
  30016. */
  30017. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30018. /**
  30019. * Creates a new raw cube texture
  30020. * @param data defines the array of data to use to create each face
  30021. * @param size defines the size of the textures
  30022. * @param format defines the format of the data
  30023. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30024. * @param generateMipMaps defines if the engine should generate the mip levels
  30025. * @param invertY defines if data must be stored with Y axis inverted
  30026. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30027. * @param compression defines the compression used (null by default)
  30028. * @returns the cube texture as an InternalTexture
  30029. */
  30030. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30031. /**
  30032. * Creates a new raw 3D texture
  30033. * @param data defines the data used to create the texture
  30034. * @param width defines the width of the texture
  30035. * @param height defines the height of the texture
  30036. * @param depth defines the depth of the texture
  30037. * @param format defines the format of the texture
  30038. * @param generateMipMaps defines if the engine must generate mip levels
  30039. * @param invertY defines if data must be stored with Y axis inverted
  30040. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30041. * @param compression defines the compressed used (can be null)
  30042. * @param textureType defines the compressed used (can be null)
  30043. * @returns a new raw 3D texture (stored in an InternalTexture)
  30044. */
  30045. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30046. private _unpackFlipYCached;
  30047. /**
  30048. * In case you are sharing the context with other applications, it might
  30049. * be interested to not cache the unpack flip y state to ensure a consistent
  30050. * value would be set.
  30051. */
  30052. enableUnpackFlipYCached: boolean;
  30053. /** @hidden */
  30054. _unpackFlipY(value: boolean): void;
  30055. /** @hidden */
  30056. _getUnpackAlignement(): number;
  30057. /**
  30058. * Update the sampling mode of a given texture
  30059. * @param samplingMode defines the required sampling mode
  30060. * @param texture defines the texture to update
  30061. */
  30062. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30063. /**
  30064. * Updates a depth texture Comparison Mode and Function.
  30065. * If the comparison Function is equal to 0, the mode will be set to none.
  30066. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30067. * @param texture The texture to set the comparison function for
  30068. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30069. */
  30070. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30071. /** @hidden */
  30072. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30073. width: number;
  30074. height: number;
  30075. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30076. /**
  30077. * Creates a depth stencil texture.
  30078. * This is only available in WebGL 2 or with the depth texture extension available.
  30079. * @param size The size of face edge in the texture.
  30080. * @param options The options defining the texture.
  30081. * @returns The texture
  30082. */
  30083. createDepthStencilTexture(size: number | {
  30084. width: number;
  30085. height: number;
  30086. }, options: DepthTextureCreationOptions): InternalTexture;
  30087. /**
  30088. * Creates a depth stencil texture.
  30089. * This is only available in WebGL 2 or with the depth texture extension available.
  30090. * @param size The size of face edge in the texture.
  30091. * @param options The options defining the texture.
  30092. * @returns The texture
  30093. */
  30094. private _createDepthStencilTexture;
  30095. /**
  30096. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30097. * @param renderTarget The render target to set the frame buffer for
  30098. */
  30099. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30100. /** @hidden */
  30101. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30102. /** @hidden */
  30103. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30104. /** @hidden */
  30105. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30106. /** @hidden */
  30107. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30108. /** @hidden */
  30109. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30110. /**
  30111. * @hidden
  30112. */
  30113. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30114. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30115. private _prepareWebGLTexture;
  30116. /** @hidden */
  30117. _releaseFramebufferObjects(texture: InternalTexture): void;
  30118. /** @hidden */
  30119. _releaseTexture(texture: InternalTexture): void;
  30120. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30121. protected _setProgram(program: WebGLProgram): void;
  30122. protected _boundUniforms: {
  30123. [key: number]: WebGLUniformLocation;
  30124. };
  30125. /**
  30126. * Binds an effect to the webGL context
  30127. * @param effect defines the effect to bind
  30128. */
  30129. bindSamplers(effect: Effect): void;
  30130. private _activateCurrentTexture;
  30131. /** @hidden */
  30132. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30133. /** @hidden */
  30134. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30135. /**
  30136. * Unbind all textures from the webGL context
  30137. */
  30138. unbindAllTextures(): void;
  30139. /**
  30140. * Sets a texture to the according uniform.
  30141. * @param channel The texture channel
  30142. * @param uniform The uniform to set
  30143. * @param texture The texture to apply
  30144. */
  30145. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30146. private _bindSamplerUniformToChannel;
  30147. private _getTextureWrapMode;
  30148. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30149. /**
  30150. * Sets an array of texture to the webGL context
  30151. * @param channel defines the channel where the texture array must be set
  30152. * @param uniform defines the associated uniform location
  30153. * @param textures defines the array of textures to bind
  30154. */
  30155. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30156. /** @hidden */
  30157. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30158. private _setTextureParameterFloat;
  30159. private _setTextureParameterInteger;
  30160. /**
  30161. * Unbind all vertex attributes from the webGL context
  30162. */
  30163. unbindAllAttributes(): void;
  30164. /**
  30165. * 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
  30166. */
  30167. releaseEffects(): void;
  30168. /**
  30169. * Dispose and release all associated resources
  30170. */
  30171. dispose(): void;
  30172. /**
  30173. * Attach a new callback raised when context lost event is fired
  30174. * @param callback defines the callback to call
  30175. */
  30176. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30177. /**
  30178. * Attach a new callback raised when context restored event is fired
  30179. * @param callback defines the callback to call
  30180. */
  30181. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30182. /**
  30183. * Get the current error code of the webGL context
  30184. * @returns the error code
  30185. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30186. */
  30187. getError(): number;
  30188. private _canRenderToFloatFramebuffer;
  30189. private _canRenderToHalfFloatFramebuffer;
  30190. private _canRenderToFramebuffer;
  30191. /** @hidden */
  30192. _getWebGLTextureType(type: number): number;
  30193. /** @hidden */
  30194. _getInternalFormat(format: number): number;
  30195. /** @hidden */
  30196. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30197. /** @hidden */
  30198. _getRGBAMultiSampleBufferFormat(type: number): number;
  30199. /** @hidden */
  30200. _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;
  30201. /**
  30202. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30203. * @returns true if the engine can be created
  30204. * @ignorenaming
  30205. */
  30206. static isSupported(): boolean;
  30207. /**
  30208. * Find the next highest power of two.
  30209. * @param x Number to start search from.
  30210. * @return Next highest power of two.
  30211. */
  30212. static CeilingPOT(x: number): number;
  30213. /**
  30214. * Find the next lowest power of two.
  30215. * @param x Number to start search from.
  30216. * @return Next lowest power of two.
  30217. */
  30218. static FloorPOT(x: number): number;
  30219. /**
  30220. * Find the nearest power of two.
  30221. * @param x Number to start search from.
  30222. * @return Next nearest power of two.
  30223. */
  30224. static NearestPOT(x: number): number;
  30225. /**
  30226. * Get the closest exponent of two
  30227. * @param value defines the value to approximate
  30228. * @param max defines the maximum value to return
  30229. * @param mode defines how to define the closest value
  30230. * @returns closest exponent of two of the given value
  30231. */
  30232. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30233. /**
  30234. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30235. * @param func - the function to be called
  30236. * @param requester - the object that will request the next frame. Falls back to window.
  30237. * @returns frame number
  30238. */
  30239. static QueueNewFrame(func: () => void, requester?: any): number;
  30240. }
  30241. }
  30242. declare module BABYLON {
  30243. /**
  30244. * Class used to store data associated with WebGL texture data for the engine
  30245. * This class should not be used directly
  30246. */
  30247. export class InternalTexture {
  30248. /** @hidden */
  30249. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  30250. /**
  30251. * The source of the texture data is unknown
  30252. */
  30253. static DATASOURCE_UNKNOWN: number;
  30254. /**
  30255. * Texture data comes from an URL
  30256. */
  30257. static DATASOURCE_URL: number;
  30258. /**
  30259. * Texture data is only used for temporary storage
  30260. */
  30261. static DATASOURCE_TEMP: number;
  30262. /**
  30263. * Texture data comes from raw data (ArrayBuffer)
  30264. */
  30265. static DATASOURCE_RAW: number;
  30266. /**
  30267. * Texture content is dynamic (video or dynamic texture)
  30268. */
  30269. static DATASOURCE_DYNAMIC: number;
  30270. /**
  30271. * Texture content is generated by rendering to it
  30272. */
  30273. static DATASOURCE_RENDERTARGET: number;
  30274. /**
  30275. * Texture content is part of a multi render target process
  30276. */
  30277. static DATASOURCE_MULTIRENDERTARGET: number;
  30278. /**
  30279. * Texture data comes from a cube data file
  30280. */
  30281. static DATASOURCE_CUBE: number;
  30282. /**
  30283. * Texture data comes from a raw cube data
  30284. */
  30285. static DATASOURCE_CUBERAW: number;
  30286. /**
  30287. * Texture data come from a prefiltered cube data file
  30288. */
  30289. static DATASOURCE_CUBEPREFILTERED: number;
  30290. /**
  30291. * Texture content is raw 3D data
  30292. */
  30293. static DATASOURCE_RAW3D: number;
  30294. /**
  30295. * Texture content is a depth texture
  30296. */
  30297. static DATASOURCE_DEPTHTEXTURE: number;
  30298. /**
  30299. * Texture data comes from a raw cube data encoded with RGBD
  30300. */
  30301. static DATASOURCE_CUBERAW_RGBD: number;
  30302. /**
  30303. * Defines if the texture is ready
  30304. */
  30305. isReady: boolean;
  30306. /**
  30307. * Defines if the texture is a cube texture
  30308. */
  30309. isCube: boolean;
  30310. /**
  30311. * Defines if the texture contains 3D data
  30312. */
  30313. is3D: boolean;
  30314. /**
  30315. * Defines if the texture contains multiview data
  30316. */
  30317. isMultiview: boolean;
  30318. /**
  30319. * Gets the URL used to load this texture
  30320. */
  30321. url: string;
  30322. /**
  30323. * Gets the sampling mode of the texture
  30324. */
  30325. samplingMode: number;
  30326. /**
  30327. * Gets a boolean indicating if the texture needs mipmaps generation
  30328. */
  30329. generateMipMaps: boolean;
  30330. /**
  30331. * Gets the number of samples used by the texture (WebGL2+ only)
  30332. */
  30333. samples: number;
  30334. /**
  30335. * Gets the type of the texture (int, float...)
  30336. */
  30337. type: number;
  30338. /**
  30339. * Gets the format of the texture (RGB, RGBA...)
  30340. */
  30341. format: number;
  30342. /**
  30343. * Observable called when the texture is loaded
  30344. */
  30345. onLoadedObservable: Observable<InternalTexture>;
  30346. /**
  30347. * Gets the width of the texture
  30348. */
  30349. width: number;
  30350. /**
  30351. * Gets the height of the texture
  30352. */
  30353. height: number;
  30354. /**
  30355. * Gets the depth of the texture
  30356. */
  30357. depth: number;
  30358. /**
  30359. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  30360. */
  30361. baseWidth: number;
  30362. /**
  30363. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  30364. */
  30365. baseHeight: number;
  30366. /**
  30367. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  30368. */
  30369. baseDepth: number;
  30370. /**
  30371. * Gets a boolean indicating if the texture is inverted on Y axis
  30372. */
  30373. invertY: boolean;
  30374. /** @hidden */
  30375. _invertVScale: boolean;
  30376. /** @hidden */
  30377. _associatedChannel: number;
  30378. /** @hidden */
  30379. _dataSource: number;
  30380. /** @hidden */
  30381. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  30382. /** @hidden */
  30383. _bufferView: Nullable<ArrayBufferView>;
  30384. /** @hidden */
  30385. _bufferViewArray: Nullable<ArrayBufferView[]>;
  30386. /** @hidden */
  30387. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  30388. /** @hidden */
  30389. _size: number;
  30390. /** @hidden */
  30391. _extension: string;
  30392. /** @hidden */
  30393. _files: Nullable<string[]>;
  30394. /** @hidden */
  30395. _workingCanvas: Nullable<HTMLCanvasElement>;
  30396. /** @hidden */
  30397. _workingContext: Nullable<CanvasRenderingContext2D>;
  30398. /** @hidden */
  30399. _framebuffer: Nullable<WebGLFramebuffer>;
  30400. /** @hidden */
  30401. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  30402. /** @hidden */
  30403. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  30404. /** @hidden */
  30405. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  30406. /** @hidden */
  30407. _attachments: Nullable<number[]>;
  30408. /** @hidden */
  30409. _cachedCoordinatesMode: Nullable<number>;
  30410. /** @hidden */
  30411. _cachedWrapU: Nullable<number>;
  30412. /** @hidden */
  30413. _cachedWrapV: Nullable<number>;
  30414. /** @hidden */
  30415. _cachedWrapR: Nullable<number>;
  30416. /** @hidden */
  30417. _cachedAnisotropicFilteringLevel: Nullable<number>;
  30418. /** @hidden */
  30419. _isDisabled: boolean;
  30420. /** @hidden */
  30421. _compression: Nullable<string>;
  30422. /** @hidden */
  30423. _generateStencilBuffer: boolean;
  30424. /** @hidden */
  30425. _generateDepthBuffer: boolean;
  30426. /** @hidden */
  30427. _comparisonFunction: number;
  30428. /** @hidden */
  30429. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  30430. /** @hidden */
  30431. _lodGenerationScale: number;
  30432. /** @hidden */
  30433. _lodGenerationOffset: number;
  30434. /** @hidden */
  30435. _colorTextureArray: Nullable<WebGLTexture>;
  30436. /** @hidden */
  30437. _depthStencilTextureArray: Nullable<WebGLTexture>;
  30438. /** @hidden */
  30439. _lodTextureHigh: Nullable<BaseTexture>;
  30440. /** @hidden */
  30441. _lodTextureMid: Nullable<BaseTexture>;
  30442. /** @hidden */
  30443. _lodTextureLow: Nullable<BaseTexture>;
  30444. /** @hidden */
  30445. _isRGBD: boolean;
  30446. /** @hidden */
  30447. _linearSpecularLOD: boolean;
  30448. /** @hidden */
  30449. _irradianceTexture: Nullable<BaseTexture>;
  30450. /** @hidden */
  30451. _webGLTexture: Nullable<WebGLTexture>;
  30452. /** @hidden */
  30453. _references: number;
  30454. private _engine;
  30455. /**
  30456. * Gets the Engine the texture belongs to.
  30457. * @returns The babylon engine
  30458. */
  30459. getEngine(): ThinEngine;
  30460. /**
  30461. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  30462. */
  30463. readonly dataSource: number;
  30464. /**
  30465. * Creates a new InternalTexture
  30466. * @param engine defines the engine to use
  30467. * @param dataSource defines the type of data that will be used
  30468. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30469. */
  30470. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  30471. /**
  30472. * Increments the number of references (ie. the number of Texture that point to it)
  30473. */
  30474. incrementReferences(): void;
  30475. /**
  30476. * Change the size of the texture (not the size of the content)
  30477. * @param width defines the new width
  30478. * @param height defines the new height
  30479. * @param depth defines the new depth (1 by default)
  30480. */
  30481. updateSize(width: int, height: int, depth?: int): void;
  30482. /** @hidden */
  30483. _rebuild(): void;
  30484. /** @hidden */
  30485. _swapAndDie(target: InternalTexture): void;
  30486. /**
  30487. * Dispose the current allocated resources
  30488. */
  30489. dispose(): void;
  30490. }
  30491. }
  30492. declare module BABYLON {
  30493. /**
  30494. * Class used to work with sound analyzer using fast fourier transform (FFT)
  30495. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30496. */
  30497. export class Analyser {
  30498. /**
  30499. * Gets or sets the smoothing
  30500. * @ignorenaming
  30501. */
  30502. SMOOTHING: number;
  30503. /**
  30504. * Gets or sets the FFT table size
  30505. * @ignorenaming
  30506. */
  30507. FFT_SIZE: number;
  30508. /**
  30509. * Gets or sets the bar graph amplitude
  30510. * @ignorenaming
  30511. */
  30512. BARGRAPHAMPLITUDE: number;
  30513. /**
  30514. * Gets or sets the position of the debug canvas
  30515. * @ignorenaming
  30516. */
  30517. DEBUGCANVASPOS: {
  30518. x: number;
  30519. y: number;
  30520. };
  30521. /**
  30522. * Gets or sets the debug canvas size
  30523. * @ignorenaming
  30524. */
  30525. DEBUGCANVASSIZE: {
  30526. width: number;
  30527. height: number;
  30528. };
  30529. private _byteFreqs;
  30530. private _byteTime;
  30531. private _floatFreqs;
  30532. private _webAudioAnalyser;
  30533. private _debugCanvas;
  30534. private _debugCanvasContext;
  30535. private _scene;
  30536. private _registerFunc;
  30537. private _audioEngine;
  30538. /**
  30539. * Creates a new analyser
  30540. * @param scene defines hosting scene
  30541. */
  30542. constructor(scene: Scene);
  30543. /**
  30544. * Get the number of data values you will have to play with for the visualization
  30545. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30546. * @returns a number
  30547. */
  30548. getFrequencyBinCount(): number;
  30549. /**
  30550. * Gets the current frequency data as a byte array
  30551. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30552. * @returns a Uint8Array
  30553. */
  30554. getByteFrequencyData(): Uint8Array;
  30555. /**
  30556. * Gets the current waveform as a byte array
  30557. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30558. * @returns a Uint8Array
  30559. */
  30560. getByteTimeDomainData(): Uint8Array;
  30561. /**
  30562. * Gets the current frequency data as a float array
  30563. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30564. * @returns a Float32Array
  30565. */
  30566. getFloatFrequencyData(): Float32Array;
  30567. /**
  30568. * Renders the debug canvas
  30569. */
  30570. drawDebugCanvas(): void;
  30571. /**
  30572. * Stops rendering the debug canvas and removes it
  30573. */
  30574. stopDebugCanvas(): void;
  30575. /**
  30576. * Connects two audio nodes
  30577. * @param inputAudioNode defines first node to connect
  30578. * @param outputAudioNode defines second node to connect
  30579. */
  30580. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30581. /**
  30582. * Releases all associated resources
  30583. */
  30584. dispose(): void;
  30585. }
  30586. }
  30587. declare module BABYLON {
  30588. /**
  30589. * This represents an audio engine and it is responsible
  30590. * to play, synchronize and analyse sounds throughout the application.
  30591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30592. */
  30593. export interface IAudioEngine extends IDisposable {
  30594. /**
  30595. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30596. */
  30597. readonly canUseWebAudio: boolean;
  30598. /**
  30599. * Gets the current AudioContext if available.
  30600. */
  30601. readonly audioContext: Nullable<AudioContext>;
  30602. /**
  30603. * The master gain node defines the global audio volume of your audio engine.
  30604. */
  30605. readonly masterGain: GainNode;
  30606. /**
  30607. * Gets whether or not mp3 are supported by your browser.
  30608. */
  30609. readonly isMP3supported: boolean;
  30610. /**
  30611. * Gets whether or not ogg are supported by your browser.
  30612. */
  30613. readonly isOGGsupported: boolean;
  30614. /**
  30615. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30616. * @ignoreNaming
  30617. */
  30618. WarnedWebAudioUnsupported: boolean;
  30619. /**
  30620. * Defines if the audio engine relies on a custom unlocked button.
  30621. * In this case, the embedded button will not be displayed.
  30622. */
  30623. useCustomUnlockedButton: boolean;
  30624. /**
  30625. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30626. */
  30627. readonly unlocked: boolean;
  30628. /**
  30629. * Event raised when audio has been unlocked on the browser.
  30630. */
  30631. onAudioUnlockedObservable: Observable<AudioEngine>;
  30632. /**
  30633. * Event raised when audio has been locked on the browser.
  30634. */
  30635. onAudioLockedObservable: Observable<AudioEngine>;
  30636. /**
  30637. * Flags the audio engine in Locked state.
  30638. * This happens due to new browser policies preventing audio to autoplay.
  30639. */
  30640. lock(): void;
  30641. /**
  30642. * Unlocks the audio engine once a user action has been done on the dom.
  30643. * This is helpful to resume play once browser policies have been satisfied.
  30644. */
  30645. unlock(): void;
  30646. }
  30647. /**
  30648. * This represents the default audio engine used in babylon.
  30649. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30651. */
  30652. export class AudioEngine implements IAudioEngine {
  30653. private _audioContext;
  30654. private _audioContextInitialized;
  30655. private _muteButton;
  30656. private _hostElement;
  30657. /**
  30658. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30659. */
  30660. canUseWebAudio: boolean;
  30661. /**
  30662. * The master gain node defines the global audio volume of your audio engine.
  30663. */
  30664. masterGain: GainNode;
  30665. /**
  30666. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30667. * @ignoreNaming
  30668. */
  30669. WarnedWebAudioUnsupported: boolean;
  30670. /**
  30671. * Gets whether or not mp3 are supported by your browser.
  30672. */
  30673. isMP3supported: boolean;
  30674. /**
  30675. * Gets whether or not ogg are supported by your browser.
  30676. */
  30677. isOGGsupported: boolean;
  30678. /**
  30679. * Gets whether audio has been unlocked on the device.
  30680. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30681. * a user interaction has happened.
  30682. */
  30683. unlocked: boolean;
  30684. /**
  30685. * Defines if the audio engine relies on a custom unlocked button.
  30686. * In this case, the embedded button will not be displayed.
  30687. */
  30688. useCustomUnlockedButton: boolean;
  30689. /**
  30690. * Event raised when audio has been unlocked on the browser.
  30691. */
  30692. onAudioUnlockedObservable: Observable<AudioEngine>;
  30693. /**
  30694. * Event raised when audio has been locked on the browser.
  30695. */
  30696. onAudioLockedObservable: Observable<AudioEngine>;
  30697. /**
  30698. * Gets the current AudioContext if available.
  30699. */
  30700. readonly audioContext: Nullable<AudioContext>;
  30701. private _connectedAnalyser;
  30702. /**
  30703. * Instantiates a new audio engine.
  30704. *
  30705. * There should be only one per page as some browsers restrict the number
  30706. * of audio contexts you can create.
  30707. * @param hostElement defines the host element where to display the mute icon if necessary
  30708. */
  30709. constructor(hostElement?: Nullable<HTMLElement>);
  30710. /**
  30711. * Flags the audio engine in Locked state.
  30712. * This happens due to new browser policies preventing audio to autoplay.
  30713. */
  30714. lock(): void;
  30715. /**
  30716. * Unlocks the audio engine once a user action has been done on the dom.
  30717. * This is helpful to resume play once browser policies have been satisfied.
  30718. */
  30719. unlock(): void;
  30720. private _resumeAudioContext;
  30721. private _initializeAudioContext;
  30722. private _tryToRun;
  30723. private _triggerRunningState;
  30724. private _triggerSuspendedState;
  30725. private _displayMuteButton;
  30726. private _moveButtonToTopLeft;
  30727. private _onResize;
  30728. private _hideMuteButton;
  30729. /**
  30730. * Destroy and release the resources associated with the audio ccontext.
  30731. */
  30732. dispose(): void;
  30733. /**
  30734. * Gets the global volume sets on the master gain.
  30735. * @returns the global volume if set or -1 otherwise
  30736. */
  30737. getGlobalVolume(): number;
  30738. /**
  30739. * Sets the global volume of your experience (sets on the master gain).
  30740. * @param newVolume Defines the new global volume of the application
  30741. */
  30742. setGlobalVolume(newVolume: number): void;
  30743. /**
  30744. * Connect the audio engine to an audio analyser allowing some amazing
  30745. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30747. * @param analyser The analyser to connect to the engine
  30748. */
  30749. connectToAnalyser(analyser: Analyser): void;
  30750. }
  30751. }
  30752. declare module BABYLON {
  30753. /**
  30754. * Interface used to present a loading screen while loading a scene
  30755. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30756. */
  30757. export interface ILoadingScreen {
  30758. /**
  30759. * Function called to display the loading screen
  30760. */
  30761. displayLoadingUI: () => void;
  30762. /**
  30763. * Function called to hide the loading screen
  30764. */
  30765. hideLoadingUI: () => void;
  30766. /**
  30767. * Gets or sets the color to use for the background
  30768. */
  30769. loadingUIBackgroundColor: string;
  30770. /**
  30771. * Gets or sets the text to display while loading
  30772. */
  30773. loadingUIText: string;
  30774. }
  30775. /**
  30776. * Class used for the default loading screen
  30777. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30778. */
  30779. export class DefaultLoadingScreen implements ILoadingScreen {
  30780. private _renderingCanvas;
  30781. private _loadingText;
  30782. private _loadingDivBackgroundColor;
  30783. private _loadingDiv;
  30784. private _loadingTextDiv;
  30785. /** Gets or sets the logo url to use for the default loading screen */
  30786. static DefaultLogoUrl: string;
  30787. /** Gets or sets the spinner url to use for the default loading screen */
  30788. static DefaultSpinnerUrl: string;
  30789. /**
  30790. * Creates a new default loading screen
  30791. * @param _renderingCanvas defines the canvas used to render the scene
  30792. * @param _loadingText defines the default text to display
  30793. * @param _loadingDivBackgroundColor defines the default background color
  30794. */
  30795. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30796. /**
  30797. * Function called to display the loading screen
  30798. */
  30799. displayLoadingUI(): void;
  30800. /**
  30801. * Function called to hide the loading screen
  30802. */
  30803. hideLoadingUI(): void;
  30804. /**
  30805. * Gets or sets the text to display while loading
  30806. */
  30807. loadingUIText: string;
  30808. /**
  30809. * Gets or sets the color to use for the background
  30810. */
  30811. loadingUIBackgroundColor: string;
  30812. private _resizeLoadingUI;
  30813. }
  30814. }
  30815. declare module BABYLON {
  30816. /**
  30817. * Interface for any object that can request an animation frame
  30818. */
  30819. export interface ICustomAnimationFrameRequester {
  30820. /**
  30821. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30822. */
  30823. renderFunction?: Function;
  30824. /**
  30825. * Called to request the next frame to render to
  30826. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30827. */
  30828. requestAnimationFrame: Function;
  30829. /**
  30830. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30831. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30832. */
  30833. requestID?: number;
  30834. }
  30835. }
  30836. declare module BABYLON {
  30837. /**
  30838. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30839. */
  30840. export class PerformanceMonitor {
  30841. private _enabled;
  30842. private _rollingFrameTime;
  30843. private _lastFrameTimeMs;
  30844. /**
  30845. * constructor
  30846. * @param frameSampleSize The number of samples required to saturate the sliding window
  30847. */
  30848. constructor(frameSampleSize?: number);
  30849. /**
  30850. * Samples current frame
  30851. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30852. */
  30853. sampleFrame(timeMs?: number): void;
  30854. /**
  30855. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30856. */
  30857. readonly averageFrameTime: number;
  30858. /**
  30859. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30860. */
  30861. readonly averageFrameTimeVariance: number;
  30862. /**
  30863. * Returns the frame time of the most recent frame
  30864. */
  30865. readonly instantaneousFrameTime: number;
  30866. /**
  30867. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30868. */
  30869. readonly averageFPS: number;
  30870. /**
  30871. * Returns the average framerate in frames per second using the most recent frame time
  30872. */
  30873. readonly instantaneousFPS: number;
  30874. /**
  30875. * Returns true if enough samples have been taken to completely fill the sliding window
  30876. */
  30877. readonly isSaturated: boolean;
  30878. /**
  30879. * Enables contributions to the sliding window sample set
  30880. */
  30881. enable(): void;
  30882. /**
  30883. * Disables contributions to the sliding window sample set
  30884. * Samples will not be interpolated over the disabled period
  30885. */
  30886. disable(): void;
  30887. /**
  30888. * Returns true if sampling is enabled
  30889. */
  30890. readonly isEnabled: boolean;
  30891. /**
  30892. * Resets performance monitor
  30893. */
  30894. reset(): void;
  30895. }
  30896. /**
  30897. * RollingAverage
  30898. *
  30899. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30900. */
  30901. export class RollingAverage {
  30902. /**
  30903. * Current average
  30904. */
  30905. average: number;
  30906. /**
  30907. * Current variance
  30908. */
  30909. variance: number;
  30910. protected _samples: Array<number>;
  30911. protected _sampleCount: number;
  30912. protected _pos: number;
  30913. protected _m2: number;
  30914. /**
  30915. * constructor
  30916. * @param length The number of samples required to saturate the sliding window
  30917. */
  30918. constructor(length: number);
  30919. /**
  30920. * Adds a sample to the sample set
  30921. * @param v The sample value
  30922. */
  30923. add(v: number): void;
  30924. /**
  30925. * Returns previously added values or null if outside of history or outside the sliding window domain
  30926. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30927. * @return Value previously recorded with add() or null if outside of range
  30928. */
  30929. history(i: number): number;
  30930. /**
  30931. * Returns true if enough samples have been taken to completely fill the sliding window
  30932. * @return true if sample-set saturated
  30933. */
  30934. isSaturated(): boolean;
  30935. /**
  30936. * Resets the rolling average (equivalent to 0 samples taken so far)
  30937. */
  30938. reset(): void;
  30939. /**
  30940. * Wraps a value around the sample range boundaries
  30941. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30942. * @return Wrapped position in sample range
  30943. */
  30944. protected _wrapPosition(i: number): number;
  30945. }
  30946. }
  30947. declare module BABYLON {
  30948. /**
  30949. * Defines the interface used by display changed events
  30950. */
  30951. export interface IDisplayChangedEventArgs {
  30952. /** Gets the vrDisplay object (if any) */
  30953. vrDisplay: Nullable<any>;
  30954. /** Gets a boolean indicating if webVR is supported */
  30955. vrSupported: boolean;
  30956. }
  30957. /**
  30958. * Defines the interface used by objects containing a viewport (like a camera)
  30959. */
  30960. interface IViewportOwnerLike {
  30961. /**
  30962. * Gets or sets the viewport
  30963. */
  30964. viewport: IViewportLike;
  30965. }
  30966. /**
  30967. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30968. */
  30969. export class Engine extends ThinEngine {
  30970. /** Defines that alpha blending is disabled */
  30971. static readonly ALPHA_DISABLE: number;
  30972. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30973. static readonly ALPHA_ADD: number;
  30974. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30975. static readonly ALPHA_COMBINE: number;
  30976. /** Defines that alpha blending to DEST - SRC * DEST */
  30977. static readonly ALPHA_SUBTRACT: number;
  30978. /** Defines that alpha blending to SRC * DEST */
  30979. static readonly ALPHA_MULTIPLY: number;
  30980. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30981. static readonly ALPHA_MAXIMIZED: number;
  30982. /** Defines that alpha blending to SRC + DEST */
  30983. static readonly ALPHA_ONEONE: number;
  30984. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30985. static readonly ALPHA_PREMULTIPLIED: number;
  30986. /**
  30987. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30988. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30989. */
  30990. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30991. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30992. static readonly ALPHA_INTERPOLATE: number;
  30993. /**
  30994. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30995. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30996. */
  30997. static readonly ALPHA_SCREENMODE: number;
  30998. /** Defines that the ressource is not delayed*/
  30999. static readonly DELAYLOADSTATE_NONE: number;
  31000. /** Defines that the ressource was successfully delay loaded */
  31001. static readonly DELAYLOADSTATE_LOADED: number;
  31002. /** Defines that the ressource is currently delay loading */
  31003. static readonly DELAYLOADSTATE_LOADING: number;
  31004. /** Defines that the ressource is delayed and has not started loading */
  31005. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31006. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31007. static readonly NEVER: number;
  31008. /** 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 */
  31009. static readonly ALWAYS: number;
  31010. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31011. static readonly LESS: number;
  31012. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31013. static readonly EQUAL: number;
  31014. /** 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 */
  31015. static readonly LEQUAL: number;
  31016. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31017. static readonly GREATER: number;
  31018. /** 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 */
  31019. static readonly GEQUAL: number;
  31020. /** 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 */
  31021. static readonly NOTEQUAL: number;
  31022. /** Passed to stencilOperation to specify that stencil value must be kept */
  31023. static readonly KEEP: number;
  31024. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31025. static readonly REPLACE: number;
  31026. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31027. static readonly INCR: number;
  31028. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31029. static readonly DECR: number;
  31030. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31031. static readonly INVERT: number;
  31032. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31033. static readonly INCR_WRAP: number;
  31034. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31035. static readonly DECR_WRAP: number;
  31036. /** Texture is not repeating outside of 0..1 UVs */
  31037. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31038. /** Texture is repeating outside of 0..1 UVs */
  31039. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31040. /** Texture is repeating and mirrored */
  31041. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31042. /** ALPHA */
  31043. static readonly TEXTUREFORMAT_ALPHA: number;
  31044. /** LUMINANCE */
  31045. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31046. /** LUMINANCE_ALPHA */
  31047. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31048. /** RGB */
  31049. static readonly TEXTUREFORMAT_RGB: number;
  31050. /** RGBA */
  31051. static readonly TEXTUREFORMAT_RGBA: number;
  31052. /** RED */
  31053. static readonly TEXTUREFORMAT_RED: number;
  31054. /** RED (2nd reference) */
  31055. static readonly TEXTUREFORMAT_R: number;
  31056. /** RG */
  31057. static readonly TEXTUREFORMAT_RG: number;
  31058. /** RED_INTEGER */
  31059. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31060. /** RED_INTEGER (2nd reference) */
  31061. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31062. /** RG_INTEGER */
  31063. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31064. /** RGB_INTEGER */
  31065. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31066. /** RGBA_INTEGER */
  31067. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31068. /** UNSIGNED_BYTE */
  31069. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31070. /** UNSIGNED_BYTE (2nd reference) */
  31071. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31072. /** FLOAT */
  31073. static readonly TEXTURETYPE_FLOAT: number;
  31074. /** HALF_FLOAT */
  31075. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31076. /** BYTE */
  31077. static readonly TEXTURETYPE_BYTE: number;
  31078. /** SHORT */
  31079. static readonly TEXTURETYPE_SHORT: number;
  31080. /** UNSIGNED_SHORT */
  31081. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31082. /** INT */
  31083. static readonly TEXTURETYPE_INT: number;
  31084. /** UNSIGNED_INT */
  31085. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31086. /** UNSIGNED_SHORT_4_4_4_4 */
  31087. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31088. /** UNSIGNED_SHORT_5_5_5_1 */
  31089. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31090. /** UNSIGNED_SHORT_5_6_5 */
  31091. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31092. /** UNSIGNED_INT_2_10_10_10_REV */
  31093. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31094. /** UNSIGNED_INT_24_8 */
  31095. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31096. /** UNSIGNED_INT_10F_11F_11F_REV */
  31097. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31098. /** UNSIGNED_INT_5_9_9_9_REV */
  31099. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31100. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31101. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31102. /** nearest is mag = nearest and min = nearest and mip = linear */
  31103. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31104. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31105. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31106. /** Trilinear is mag = linear and min = linear and mip = linear */
  31107. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31108. /** nearest is mag = nearest and min = nearest and mip = linear */
  31109. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31110. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31111. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31112. /** Trilinear is mag = linear and min = linear and mip = linear */
  31113. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31114. /** mag = nearest and min = nearest and mip = nearest */
  31115. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31116. /** mag = nearest and min = linear and mip = nearest */
  31117. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31118. /** mag = nearest and min = linear and mip = linear */
  31119. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31120. /** mag = nearest and min = linear and mip = none */
  31121. static readonly TEXTURE_NEAREST_LINEAR: number;
  31122. /** mag = nearest and min = nearest and mip = none */
  31123. static readonly TEXTURE_NEAREST_NEAREST: number;
  31124. /** mag = linear and min = nearest and mip = nearest */
  31125. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31126. /** mag = linear and min = nearest and mip = linear */
  31127. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31128. /** mag = linear and min = linear and mip = none */
  31129. static readonly TEXTURE_LINEAR_LINEAR: number;
  31130. /** mag = linear and min = nearest and mip = none */
  31131. static readonly TEXTURE_LINEAR_NEAREST: number;
  31132. /** Explicit coordinates mode */
  31133. static readonly TEXTURE_EXPLICIT_MODE: number;
  31134. /** Spherical coordinates mode */
  31135. static readonly TEXTURE_SPHERICAL_MODE: number;
  31136. /** Planar coordinates mode */
  31137. static readonly TEXTURE_PLANAR_MODE: number;
  31138. /** Cubic coordinates mode */
  31139. static readonly TEXTURE_CUBIC_MODE: number;
  31140. /** Projection coordinates mode */
  31141. static readonly TEXTURE_PROJECTION_MODE: number;
  31142. /** Skybox coordinates mode */
  31143. static readonly TEXTURE_SKYBOX_MODE: number;
  31144. /** Inverse Cubic coordinates mode */
  31145. static readonly TEXTURE_INVCUBIC_MODE: number;
  31146. /** Equirectangular coordinates mode */
  31147. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  31148. /** Equirectangular Fixed coordinates mode */
  31149. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  31150. /** Equirectangular Fixed Mirrored coordinates mode */
  31151. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  31152. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  31153. static readonly SCALEMODE_FLOOR: number;
  31154. /** Defines that texture rescaling will look for the nearest power of 2 size */
  31155. static readonly SCALEMODE_NEAREST: number;
  31156. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  31157. static readonly SCALEMODE_CEILING: number;
  31158. /**
  31159. * Returns the current npm package of the sdk
  31160. */
  31161. static readonly NpmPackage: string;
  31162. /**
  31163. * Returns the current version of the framework
  31164. */
  31165. static readonly Version: string;
  31166. /** Gets the list of created engines */
  31167. static readonly Instances: Engine[];
  31168. /**
  31169. * Gets the latest created engine
  31170. */
  31171. static readonly LastCreatedEngine: Nullable<Engine>;
  31172. /**
  31173. * Gets the latest created scene
  31174. */
  31175. static readonly LastCreatedScene: Nullable<Scene>;
  31176. /**
  31177. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  31178. * @param flag defines which part of the materials must be marked as dirty
  31179. * @param predicate defines a predicate used to filter which materials should be affected
  31180. */
  31181. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  31182. /**
  31183. * Method called to create the default loading screen.
  31184. * This can be overriden in your own app.
  31185. * @param canvas The rendering canvas element
  31186. * @returns The loading screen
  31187. */
  31188. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31189. /**
  31190. * Method called to create the default rescale post process on each engine.
  31191. */
  31192. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31193. /**
  31194. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31195. **/
  31196. enableOfflineSupport: boolean;
  31197. /**
  31198. * 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)
  31199. **/
  31200. disableManifestCheck: boolean;
  31201. /**
  31202. * Gets the list of created scenes
  31203. */
  31204. scenes: Scene[];
  31205. /**
  31206. * Event raised when a new scene is created
  31207. */
  31208. onNewSceneAddedObservable: Observable<Scene>;
  31209. /**
  31210. * Gets the list of created postprocesses
  31211. */
  31212. postProcesses: PostProcess[];
  31213. /**
  31214. * Gets a boolean indicating if the pointer is currently locked
  31215. */
  31216. isPointerLock: boolean;
  31217. /**
  31218. * Observable event triggered each time the rendering canvas is resized
  31219. */
  31220. onResizeObservable: Observable<Engine>;
  31221. /**
  31222. * Observable event triggered each time the canvas loses focus
  31223. */
  31224. onCanvasBlurObservable: Observable<Engine>;
  31225. /**
  31226. * Observable event triggered each time the canvas gains focus
  31227. */
  31228. onCanvasFocusObservable: Observable<Engine>;
  31229. /**
  31230. * Observable event triggered each time the canvas receives pointerout event
  31231. */
  31232. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31233. /**
  31234. * Observable event triggered before each texture is initialized
  31235. */
  31236. onBeforeTextureInitObservable: Observable<Texture>;
  31237. /**
  31238. * Observable raised when the engine begins a new frame
  31239. */
  31240. onBeginFrameObservable: Observable<Engine>;
  31241. /**
  31242. * If set, will be used to request the next animation frame for the render loop
  31243. */
  31244. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31245. /**
  31246. * Observable raised when the engine ends the current frame
  31247. */
  31248. onEndFrameObservable: Observable<Engine>;
  31249. /**
  31250. * Observable raised when the engine is about to compile a shader
  31251. */
  31252. onBeforeShaderCompilationObservable: Observable<Engine>;
  31253. /**
  31254. * Observable raised when the engine has jsut compiled a shader
  31255. */
  31256. onAfterShaderCompilationObservable: Observable<Engine>;
  31257. /**
  31258. * Gets the audio engine
  31259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31260. * @ignorenaming
  31261. */
  31262. static audioEngine: IAudioEngine;
  31263. /**
  31264. * Default AudioEngine factory responsible of creating the Audio Engine.
  31265. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31266. */
  31267. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31268. /**
  31269. * Default offline support factory responsible of creating a tool used to store data locally.
  31270. * By default, this will create a Database object if the workload has been embedded.
  31271. */
  31272. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31273. private _loadingScreen;
  31274. private _pointerLockRequested;
  31275. private _dummyFramebuffer;
  31276. private _rescalePostProcess;
  31277. /** @hidden */
  31278. protected _alphaMode: number;
  31279. /** @hidden */
  31280. protected _alphaEquation: number;
  31281. private _deterministicLockstep;
  31282. private _lockstepMaxSteps;
  31283. protected readonly _supportsHardwareTextureRescaling: boolean;
  31284. private _fps;
  31285. private _deltaTime;
  31286. /**
  31287. * Turn this value on if you want to pause FPS computation when in background
  31288. */
  31289. disablePerformanceMonitorInBackground: boolean;
  31290. private _performanceMonitor;
  31291. /**
  31292. * Gets the performance monitor attached to this engine
  31293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31294. */
  31295. readonly performanceMonitor: PerformanceMonitor;
  31296. private _onFocus;
  31297. private _onBlur;
  31298. private _onCanvasPointerOut;
  31299. private _onCanvasBlur;
  31300. private _onCanvasFocus;
  31301. private _onFullscreenChange;
  31302. private _onPointerLockChange;
  31303. /**
  31304. * Creates a new engine
  31305. * @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
  31306. * @param antialias defines enable antialiasing (default: false)
  31307. * @param options defines further options to be sent to the getContext() function
  31308. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31309. */
  31310. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31311. /**
  31312. * Gets current aspect ratio
  31313. * @param viewportOwner defines the camera to use to get the aspect ratio
  31314. * @param useScreen defines if screen size must be used (or the current render target if any)
  31315. * @returns a number defining the aspect ratio
  31316. */
  31317. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31318. /**
  31319. * Gets current screen aspect ratio
  31320. * @returns a number defining the aspect ratio
  31321. */
  31322. getScreenAspectRatio(): number;
  31323. /**
  31324. * Gets host document
  31325. * @returns the host document object
  31326. */
  31327. getHostDocument(): Document;
  31328. /**
  31329. * Gets the client rect of the HTML canvas attached with the current webGL context
  31330. * @returns a client rectanglee
  31331. */
  31332. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31333. /**
  31334. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31335. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31336. * @returns true if engine is in deterministic lock step mode
  31337. */
  31338. isDeterministicLockStep(): boolean;
  31339. /**
  31340. * Gets the max steps when engine is running in deterministic lock step
  31341. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31342. * @returns the max steps
  31343. */
  31344. getLockstepMaxSteps(): number;
  31345. /**
  31346. * Force the mipmap generation for the given render target texture
  31347. * @param texture defines the render target texture to use
  31348. */
  31349. generateMipMapsForCubemap(texture: InternalTexture): void;
  31350. /** States */
  31351. /**
  31352. * Set various states to the webGL context
  31353. * @param culling defines backface culling state
  31354. * @param zOffset defines the value to apply to zOffset (0 by default)
  31355. * @param force defines if states must be applied even if cache is up to date
  31356. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31357. */
  31358. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31359. /**
  31360. * Set the z offset to apply to current rendering
  31361. * @param value defines the offset to apply
  31362. */
  31363. setZOffset(value: number): void;
  31364. /**
  31365. * Gets the current value of the zOffset
  31366. * @returns the current zOffset state
  31367. */
  31368. getZOffset(): number;
  31369. /**
  31370. * Enable or disable depth buffering
  31371. * @param enable defines the state to set
  31372. */
  31373. setDepthBuffer(enable: boolean): void;
  31374. /**
  31375. * Gets a boolean indicating if depth writing is enabled
  31376. * @returns the current depth writing state
  31377. */
  31378. getDepthWrite(): boolean;
  31379. /**
  31380. * Enable or disable depth writing
  31381. * @param enable defines the state to set
  31382. */
  31383. setDepthWrite(enable: boolean): void;
  31384. /**
  31385. * Enable or disable color writing
  31386. * @param enable defines the state to set
  31387. */
  31388. setColorWrite(enable: boolean): void;
  31389. /**
  31390. * Gets a boolean indicating if color writing is enabled
  31391. * @returns the current color writing state
  31392. */
  31393. getColorWrite(): boolean;
  31394. /**
  31395. * Sets alpha constants used by some alpha blending modes
  31396. * @param r defines the red component
  31397. * @param g defines the green component
  31398. * @param b defines the blue component
  31399. * @param a defines the alpha component
  31400. */
  31401. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31402. /**
  31403. * Sets the current alpha mode
  31404. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31405. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31406. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31407. */
  31408. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31409. /**
  31410. * Gets the current alpha mode
  31411. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31412. * @returns the current alpha mode
  31413. */
  31414. getAlphaMode(): number;
  31415. /**
  31416. * Sets the current alpha equation
  31417. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  31418. */
  31419. setAlphaEquation(equation: number): void;
  31420. /**
  31421. * Gets the current alpha equation.
  31422. * @returns the current alpha equation
  31423. */
  31424. getAlphaEquation(): number;
  31425. /**
  31426. * Gets a boolean indicating if stencil buffer is enabled
  31427. * @returns the current stencil buffer state
  31428. */
  31429. getStencilBuffer(): boolean;
  31430. /**
  31431. * Enable or disable the stencil buffer
  31432. * @param enable defines if the stencil buffer must be enabled or disabled
  31433. */
  31434. setStencilBuffer(enable: boolean): void;
  31435. /**
  31436. * Gets the current stencil mask
  31437. * @returns a number defining the new stencil mask to use
  31438. */
  31439. getStencilMask(): number;
  31440. /**
  31441. * Sets the current stencil mask
  31442. * @param mask defines the new stencil mask to use
  31443. */
  31444. setStencilMask(mask: number): void;
  31445. /**
  31446. * Gets the current stencil function
  31447. * @returns a number defining the stencil function to use
  31448. */
  31449. getStencilFunction(): number;
  31450. /**
  31451. * Gets the current stencil reference value
  31452. * @returns a number defining the stencil reference value to use
  31453. */
  31454. getStencilFunctionReference(): number;
  31455. /**
  31456. * Gets the current stencil mask
  31457. * @returns a number defining the stencil mask to use
  31458. */
  31459. getStencilFunctionMask(): number;
  31460. /**
  31461. * Sets the current stencil function
  31462. * @param stencilFunc defines the new stencil function to use
  31463. */
  31464. setStencilFunction(stencilFunc: number): void;
  31465. /**
  31466. * Sets the current stencil reference
  31467. * @param reference defines the new stencil reference to use
  31468. */
  31469. setStencilFunctionReference(reference: number): void;
  31470. /**
  31471. * Sets the current stencil mask
  31472. * @param mask defines the new stencil mask to use
  31473. */
  31474. setStencilFunctionMask(mask: number): void;
  31475. /**
  31476. * Gets the current stencil operation when stencil fails
  31477. * @returns a number defining stencil operation to use when stencil fails
  31478. */
  31479. getStencilOperationFail(): number;
  31480. /**
  31481. * Gets the current stencil operation when depth fails
  31482. * @returns a number defining stencil operation to use when depth fails
  31483. */
  31484. getStencilOperationDepthFail(): number;
  31485. /**
  31486. * Gets the current stencil operation when stencil passes
  31487. * @returns a number defining stencil operation to use when stencil passes
  31488. */
  31489. getStencilOperationPass(): number;
  31490. /**
  31491. * Sets the stencil operation to use when stencil fails
  31492. * @param operation defines the stencil operation to use when stencil fails
  31493. */
  31494. setStencilOperationFail(operation: number): void;
  31495. /**
  31496. * Sets the stencil operation to use when depth fails
  31497. * @param operation defines the stencil operation to use when depth fails
  31498. */
  31499. setStencilOperationDepthFail(operation: number): void;
  31500. /**
  31501. * Sets the stencil operation to use when stencil passes
  31502. * @param operation defines the stencil operation to use when stencil passes
  31503. */
  31504. setStencilOperationPass(operation: number): void;
  31505. /**
  31506. * Sets a boolean indicating if the dithering state is enabled or disabled
  31507. * @param value defines the dithering state
  31508. */
  31509. setDitheringState(value: boolean): void;
  31510. /**
  31511. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31512. * @param value defines the rasterizer state
  31513. */
  31514. setRasterizerState(value: boolean): void;
  31515. /**
  31516. * Gets the current depth function
  31517. * @returns a number defining the depth function
  31518. */
  31519. getDepthFunction(): Nullable<number>;
  31520. /**
  31521. * Sets the current depth function
  31522. * @param depthFunc defines the function to use
  31523. */
  31524. setDepthFunction(depthFunc: number): void;
  31525. /**
  31526. * Sets the current depth function to GREATER
  31527. */
  31528. setDepthFunctionToGreater(): void;
  31529. /**
  31530. * Sets the current depth function to GEQUAL
  31531. */
  31532. setDepthFunctionToGreaterOrEqual(): void;
  31533. /**
  31534. * Sets the current depth function to LESS
  31535. */
  31536. setDepthFunctionToLess(): void;
  31537. /**
  31538. * Sets the current depth function to LEQUAL
  31539. */
  31540. setDepthFunctionToLessOrEqual(): void;
  31541. private _cachedStencilBuffer;
  31542. private _cachedStencilFunction;
  31543. private _cachedStencilMask;
  31544. private _cachedStencilOperationPass;
  31545. private _cachedStencilOperationFail;
  31546. private _cachedStencilOperationDepthFail;
  31547. private _cachedStencilReference;
  31548. /**
  31549. * Caches the the state of the stencil buffer
  31550. */
  31551. cacheStencilState(): void;
  31552. /**
  31553. * Restores the state of the stencil buffer
  31554. */
  31555. restoreStencilState(): void;
  31556. /**
  31557. * Directly set the WebGL Viewport
  31558. * @param x defines the x coordinate of the viewport (in screen space)
  31559. * @param y defines the y coordinate of the viewport (in screen space)
  31560. * @param width defines the width of the viewport (in screen space)
  31561. * @param height defines the height of the viewport (in screen space)
  31562. * @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
  31563. */
  31564. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31565. /**
  31566. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31567. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31568. * @param y defines the y-coordinate of the corner of the clear rectangle
  31569. * @param width defines the width of the clear rectangle
  31570. * @param height defines the height of the clear rectangle
  31571. * @param clearColor defines the clear color
  31572. */
  31573. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31574. /**
  31575. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31576. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31577. * @param y defines the y-coordinate of the corner of the clear rectangle
  31578. * @param width defines the width of the clear rectangle
  31579. * @param height defines the height of the clear rectangle
  31580. */
  31581. enableScissor(x: number, y: number, width: number, height: number): void;
  31582. /**
  31583. * Disable previously set scissor test rectangle
  31584. */
  31585. disableScissor(): void;
  31586. /**
  31587. * Initializes a webVR display and starts listening to display change events
  31588. * The onVRDisplayChangedObservable will be notified upon these changes
  31589. * @returns The onVRDisplayChangedObservable
  31590. */
  31591. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31592. /** @hidden */
  31593. _prepareVRComponent(): void;
  31594. /** @hidden */
  31595. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  31596. /** @hidden */
  31597. _submitVRFrame(): void;
  31598. /**
  31599. * Call this function to leave webVR mode
  31600. * Will do nothing if webVR is not supported or if there is no webVR device
  31601. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31602. */
  31603. disableVR(): void;
  31604. /**
  31605. * Gets a boolean indicating that the system is in VR mode and is presenting
  31606. * @returns true if VR mode is engaged
  31607. */
  31608. isVRPresenting(): boolean;
  31609. /** @hidden */
  31610. _requestVRFrame(): void;
  31611. /** @hidden */
  31612. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  31613. /**
  31614. * Gets the source code of the vertex shader associated with a specific webGL program
  31615. * @param program defines the program to use
  31616. * @returns a string containing the source code of the vertex shader associated with the program
  31617. */
  31618. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  31619. /**
  31620. * Gets the source code of the fragment shader associated with a specific webGL program
  31621. * @param program defines the program to use
  31622. * @returns a string containing the source code of the fragment shader associated with the program
  31623. */
  31624. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  31625. /**
  31626. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31627. * @param x defines the x coordinate of the rectangle where pixels must be read
  31628. * @param y defines the y coordinate of the rectangle where pixels must be read
  31629. * @param width defines the width of the rectangle where pixels must be read
  31630. * @param height defines the height of the rectangle where pixels must be read
  31631. * @returns a Uint8Array containing RGBA colors
  31632. */
  31633. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  31634. /**
  31635. * Sets a depth stencil texture from a render target to the according uniform.
  31636. * @param channel The texture channel
  31637. * @param uniform The uniform to set
  31638. * @param texture The render target texture containing the depth stencil texture to apply
  31639. */
  31640. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  31641. /**
  31642. * Sets a texture to the webGL context from a postprocess
  31643. * @param channel defines the channel to use
  31644. * @param postProcess defines the source postprocess
  31645. */
  31646. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  31647. /**
  31648. * Binds the output of the passed in post process to the texture channel specified
  31649. * @param channel The channel the texture should be bound to
  31650. * @param postProcess The post process which's output should be bound
  31651. */
  31652. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  31653. /** @hidden */
  31654. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  31655. protected _rebuildBuffers(): void;
  31656. _renderLoop(): void;
  31657. /**
  31658. * Toggle full screen mode
  31659. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31660. */
  31661. switchFullscreen(requestPointerLock: boolean): void;
  31662. /**
  31663. * Enters full screen mode
  31664. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31665. */
  31666. enterFullscreen(requestPointerLock: boolean): void;
  31667. /**
  31668. * Exits full screen mode
  31669. */
  31670. exitFullscreen(): void;
  31671. /**
  31672. * Enters Pointerlock mode
  31673. */
  31674. enterPointerlock(): void;
  31675. /**
  31676. * Exits Pointerlock mode
  31677. */
  31678. exitPointerlock(): void;
  31679. /**
  31680. * Begin a new frame
  31681. */
  31682. beginFrame(): void;
  31683. /**
  31684. * Enf the current frame
  31685. */
  31686. endFrame(): void;
  31687. resize(): void;
  31688. /**
  31689. * Set the compressed texture format to use, based on the formats you have, and the formats
  31690. * supported by the hardware / browser.
  31691. *
  31692. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31693. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31694. * to API arguments needed to compressed textures. This puts the burden on the container
  31695. * generator to house the arcane code for determining these for current & future formats.
  31696. *
  31697. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31698. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31699. *
  31700. * Note: The result of this call is not taken into account when a texture is base64.
  31701. *
  31702. * @param formatsAvailable defines the list of those format families you have created
  31703. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31704. *
  31705. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31706. * @returns The extension selected.
  31707. */
  31708. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31709. /**
  31710. * Force a specific size of the canvas
  31711. * @param width defines the new canvas' width
  31712. * @param height defines the new canvas' height
  31713. */
  31714. setSize(width: number, height: number): void;
  31715. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31717. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31718. _releaseTexture(texture: InternalTexture): void;
  31719. /**
  31720. * @hidden
  31721. * Rescales a texture
  31722. * @param source input texutre
  31723. * @param destination destination texture
  31724. * @param scene scene to use to render the resize
  31725. * @param internalFormat format to use when resizing
  31726. * @param onComplete callback to be called when resize has completed
  31727. */
  31728. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31729. /**
  31730. * Gets the current framerate
  31731. * @returns a number representing the framerate
  31732. */
  31733. getFps(): number;
  31734. /**
  31735. * Gets the time spent between current and previous frame
  31736. * @returns a number representing the delta time in ms
  31737. */
  31738. getDeltaTime(): number;
  31739. private _measureFps;
  31740. /**
  31741. * Creates a new render target texture
  31742. * @param size defines the size of the texture
  31743. * @param options defines the options used to create the texture
  31744. * @returns a new render target texture stored in an InternalTexture
  31745. */
  31746. createRenderTargetTexture(size: number | {
  31747. width: number;
  31748. height: number;
  31749. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  31750. /**
  31751. * Updates the sample count of a render target texture
  31752. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31753. * @param texture defines the texture to update
  31754. * @param samples defines the sample count to set
  31755. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31756. */
  31757. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31758. /** @hidden */
  31759. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31760. dispose(): void;
  31761. private _disableTouchAction;
  31762. /**
  31763. * Display the loading screen
  31764. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31765. */
  31766. displayLoadingUI(): void;
  31767. /**
  31768. * Hide the loading screen
  31769. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31770. */
  31771. hideLoadingUI(): void;
  31772. /**
  31773. * Gets the current loading screen object
  31774. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31775. */
  31776. /**
  31777. * Sets the current loading screen object
  31778. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31779. */
  31780. loadingScreen: ILoadingScreen;
  31781. /**
  31782. * Sets the current loading screen text
  31783. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31784. */
  31785. loadingUIText: string;
  31786. /**
  31787. * Sets the current loading screen background color
  31788. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31789. */
  31790. loadingUIBackgroundColor: string;
  31791. /** Pointerlock and fullscreen */
  31792. /**
  31793. * Ask the browser to promote the current element to pointerlock mode
  31794. * @param element defines the DOM element to promote
  31795. */
  31796. static _RequestPointerlock(element: HTMLElement): void;
  31797. /**
  31798. * Asks the browser to exit pointerlock mode
  31799. */
  31800. static _ExitPointerlock(): void;
  31801. /**
  31802. * Ask the browser to promote the current element to fullscreen rendering mode
  31803. * @param element defines the DOM element to promote
  31804. */
  31805. static _RequestFullscreen(element: HTMLElement): void;
  31806. /**
  31807. * Asks the browser to exit fullscreen mode
  31808. */
  31809. static _ExitFullscreen(): void;
  31810. }
  31811. }
  31812. declare module BABYLON {
  31813. /**
  31814. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31815. * during the life time of the application.
  31816. */
  31817. export class EngineStore {
  31818. /** Gets the list of created engines */
  31819. static Instances: Engine[];
  31820. /** @hidden */
  31821. static _LastCreatedScene: Nullable<Scene>;
  31822. /**
  31823. * Gets the latest created engine
  31824. */
  31825. static readonly LastCreatedEngine: Nullable<Engine>;
  31826. /**
  31827. * Gets the latest created scene
  31828. */
  31829. static readonly LastCreatedScene: Nullable<Scene>;
  31830. /**
  31831. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31832. * @ignorenaming
  31833. */
  31834. static UseFallbackTexture: boolean;
  31835. /**
  31836. * Texture content used if a texture cannot loaded
  31837. * @ignorenaming
  31838. */
  31839. static FallbackTexture: string;
  31840. }
  31841. }
  31842. declare module BABYLON {
  31843. /**
  31844. * Helper class that provides a small promise polyfill
  31845. */
  31846. export class PromisePolyfill {
  31847. /**
  31848. * Static function used to check if the polyfill is required
  31849. * If this is the case then the function will inject the polyfill to window.Promise
  31850. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31851. */
  31852. static Apply(force?: boolean): void;
  31853. }
  31854. }
  31855. declare module BABYLON {
  31856. /**
  31857. * Interface for screenshot methods with describe argument called `size` as object with options
  31858. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31859. */
  31860. export interface IScreenshotSize {
  31861. /**
  31862. * number in pixels for canvas height
  31863. */
  31864. height?: number;
  31865. /**
  31866. * multiplier allowing render at a higher or lower resolution
  31867. * If value is defined then height and width will be ignored and taken from camera
  31868. */
  31869. precision?: number;
  31870. /**
  31871. * number in pixels for canvas width
  31872. */
  31873. width?: number;
  31874. }
  31875. }
  31876. declare module BABYLON {
  31877. interface IColor4Like {
  31878. r: float;
  31879. g: float;
  31880. b: float;
  31881. a: float;
  31882. }
  31883. /**
  31884. * Class containing a set of static utilities functions
  31885. */
  31886. export class Tools {
  31887. /**
  31888. * Gets or sets the base URL to use to load assets
  31889. */
  31890. static BaseUrl: string;
  31891. /**
  31892. * Enable/Disable Custom HTTP Request Headers globally.
  31893. * default = false
  31894. * @see CustomRequestHeaders
  31895. */
  31896. static UseCustomRequestHeaders: boolean;
  31897. /**
  31898. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31899. * i.e. when loading files, where the server/service expects an Authorization header
  31900. */
  31901. static CustomRequestHeaders: {
  31902. [key: string]: string;
  31903. };
  31904. /**
  31905. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31906. */
  31907. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31908. /**
  31909. * Default behaviour for cors in the application.
  31910. * It can be a string if the expected behavior is identical in the entire app.
  31911. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31912. */
  31913. static CorsBehavior: string | ((url: string | string[]) => string);
  31914. /**
  31915. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31916. * @ignorenaming
  31917. */
  31918. static UseFallbackTexture: boolean;
  31919. /**
  31920. * Use this object to register external classes like custom textures or material
  31921. * to allow the laoders to instantiate them
  31922. */
  31923. static RegisteredExternalClasses: {
  31924. [key: string]: Object;
  31925. };
  31926. /**
  31927. * Texture content used if a texture cannot loaded
  31928. * @ignorenaming
  31929. */
  31930. static fallbackTexture: string;
  31931. /**
  31932. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31933. * @param u defines the coordinate on X axis
  31934. * @param v defines the coordinate on Y axis
  31935. * @param width defines the width of the source data
  31936. * @param height defines the height of the source data
  31937. * @param pixels defines the source byte array
  31938. * @param color defines the output color
  31939. */
  31940. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31941. /**
  31942. * Interpolates between a and b via alpha
  31943. * @param a The lower value (returned when alpha = 0)
  31944. * @param b The upper value (returned when alpha = 1)
  31945. * @param alpha The interpolation-factor
  31946. * @return The mixed value
  31947. */
  31948. static Mix(a: number, b: number, alpha: number): number;
  31949. /**
  31950. * Tries to instantiate a new object from a given class name
  31951. * @param className defines the class name to instantiate
  31952. * @returns the new object or null if the system was not able to do the instantiation
  31953. */
  31954. static Instantiate(className: string): any;
  31955. /**
  31956. * Provides a slice function that will work even on IE
  31957. * @param data defines the array to slice
  31958. * @param start defines the start of the data (optional)
  31959. * @param end defines the end of the data (optional)
  31960. * @returns the new sliced array
  31961. */
  31962. static Slice<T>(data: T, start?: number, end?: number): T;
  31963. /**
  31964. * Polyfill for setImmediate
  31965. * @param action defines the action to execute after the current execution block
  31966. */
  31967. static SetImmediate(action: () => void): void;
  31968. /**
  31969. * Function indicating if a number is an exponent of 2
  31970. * @param value defines the value to test
  31971. * @returns true if the value is an exponent of 2
  31972. */
  31973. static IsExponentOfTwo(value: number): boolean;
  31974. private static _tmpFloatArray;
  31975. /**
  31976. * Returns the nearest 32-bit single precision float representation of a Number
  31977. * @param value A Number. If the parameter is of a different type, it will get converted
  31978. * to a number or to NaN if it cannot be converted
  31979. * @returns number
  31980. */
  31981. static FloatRound(value: number): number;
  31982. /**
  31983. * Extracts the filename from a path
  31984. * @param path defines the path to use
  31985. * @returns the filename
  31986. */
  31987. static GetFilename(path: string): string;
  31988. /**
  31989. * Extracts the "folder" part of a path (everything before the filename).
  31990. * @param uri The URI to extract the info from
  31991. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31992. * @returns The "folder" part of the path
  31993. */
  31994. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31995. /**
  31996. * Extracts text content from a DOM element hierarchy
  31997. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31998. */
  31999. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32000. /**
  32001. * Convert an angle in radians to degrees
  32002. * @param angle defines the angle to convert
  32003. * @returns the angle in degrees
  32004. */
  32005. static ToDegrees(angle: number): number;
  32006. /**
  32007. * Convert an angle in degrees to radians
  32008. * @param angle defines the angle to convert
  32009. * @returns the angle in radians
  32010. */
  32011. static ToRadians(angle: number): number;
  32012. /**
  32013. * Encode a buffer to a base64 string
  32014. * @param buffer defines the buffer to encode
  32015. * @returns the encoded string
  32016. */
  32017. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32018. /**
  32019. * Returns an array if obj is not an array
  32020. * @param obj defines the object to evaluate as an array
  32021. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32022. * @returns either obj directly if obj is an array or a new array containing obj
  32023. */
  32024. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32025. /**
  32026. * Gets the pointer prefix to use
  32027. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32028. */
  32029. static GetPointerPrefix(): string;
  32030. /**
  32031. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32032. * @param url define the url we are trying
  32033. * @param element define the dom element where to configure the cors policy
  32034. */
  32035. static SetCorsBehavior(url: string | string[], element: {
  32036. crossOrigin: string | null;
  32037. }): void;
  32038. /**
  32039. * Removes unwanted characters from an url
  32040. * @param url defines the url to clean
  32041. * @returns the cleaned url
  32042. */
  32043. static CleanUrl(url: string): string;
  32044. /**
  32045. * Gets or sets a function used to pre-process url before using them to load assets
  32046. */
  32047. static PreprocessUrl: (url: string) => string;
  32048. /**
  32049. * Loads an image as an HTMLImageElement.
  32050. * @param input url string, ArrayBuffer, or Blob to load
  32051. * @param onLoad callback called when the image successfully loads
  32052. * @param onError callback called when the image fails to load
  32053. * @param offlineProvider offline provider for caching
  32054. * @returns the HTMLImageElement of the loaded image
  32055. */
  32056. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32057. /**
  32058. * Loads a file
  32059. * @param url url string, ArrayBuffer, or Blob to load
  32060. * @param onSuccess callback called when the file successfully loads
  32061. * @param onProgress callback called while file is loading (if the server supports this mode)
  32062. * @param offlineProvider defines the offline provider for caching
  32063. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32064. * @param onError callback called when the file fails to load
  32065. * @returns a file request object
  32066. */
  32067. 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;
  32068. /**
  32069. * Loads a file from a url
  32070. * @param url the file url to load
  32071. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32072. */
  32073. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32074. /**
  32075. * Load a script (identified by an url). When the url returns, the
  32076. * content of this file is added into a new script element, attached to the DOM (body element)
  32077. * @param scriptUrl defines the url of the script to laod
  32078. * @param onSuccess defines the callback called when the script is loaded
  32079. * @param onError defines the callback to call if an error occurs
  32080. * @param scriptId defines the id of the script element
  32081. */
  32082. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32083. /**
  32084. * Load an asynchronous script (identified by an url). When the url returns, the
  32085. * content of this file is added into a new script element, attached to the DOM (body element)
  32086. * @param scriptUrl defines the url of the script to laod
  32087. * @param scriptId defines the id of the script element
  32088. * @returns a promise request object
  32089. */
  32090. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32091. /**
  32092. * Loads a file from a blob
  32093. * @param fileToLoad defines the blob to use
  32094. * @param callback defines the callback to call when data is loaded
  32095. * @param progressCallback defines the callback to call during loading process
  32096. * @returns a file request object
  32097. */
  32098. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32099. /**
  32100. * Loads a file
  32101. * @param fileToLoad defines the file to load
  32102. * @param callback defines the callback to call when data is loaded
  32103. * @param progressCallBack defines the callback to call during loading process
  32104. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32105. * @returns a file request object
  32106. */
  32107. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32108. /**
  32109. * Creates a data url from a given string content
  32110. * @param content defines the content to convert
  32111. * @returns the new data url link
  32112. */
  32113. static FileAsURL(content: string): string;
  32114. /**
  32115. * Format the given number to a specific decimal format
  32116. * @param value defines the number to format
  32117. * @param decimals defines the number of decimals to use
  32118. * @returns the formatted string
  32119. */
  32120. static Format(value: number, decimals?: number): string;
  32121. /**
  32122. * Tries to copy an object by duplicating every property
  32123. * @param source defines the source object
  32124. * @param destination defines the target object
  32125. * @param doNotCopyList defines a list of properties to avoid
  32126. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32127. */
  32128. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32129. /**
  32130. * Gets a boolean indicating if the given object has no own property
  32131. * @param obj defines the object to test
  32132. * @returns true if object has no own property
  32133. */
  32134. static IsEmpty(obj: any): boolean;
  32135. /**
  32136. * Function used to register events at window level
  32137. * @param windowElement defines the Window object to use
  32138. * @param events defines the events to register
  32139. */
  32140. static RegisterTopRootEvents(windowElement: Window, events: {
  32141. name: string;
  32142. handler: Nullable<(e: FocusEvent) => any>;
  32143. }[]): void;
  32144. /**
  32145. * Function used to unregister events from window level
  32146. * @param windowElement defines the Window object to use
  32147. * @param events defines the events to unregister
  32148. */
  32149. static UnregisterTopRootEvents(windowElement: Window, events: {
  32150. name: string;
  32151. handler: Nullable<(e: FocusEvent) => any>;
  32152. }[]): void;
  32153. /**
  32154. * @ignore
  32155. */
  32156. static _ScreenshotCanvas: HTMLCanvasElement;
  32157. /**
  32158. * Dumps the current bound framebuffer
  32159. * @param width defines the rendering width
  32160. * @param height defines the rendering height
  32161. * @param engine defines the hosting engine
  32162. * @param successCallback defines the callback triggered once the data are available
  32163. * @param mimeType defines the mime type of the result
  32164. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32165. */
  32166. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32167. /**
  32168. * Converts the canvas data to blob.
  32169. * This acts as a polyfill for browsers not supporting the to blob function.
  32170. * @param canvas Defines the canvas to extract the data from
  32171. * @param successCallback Defines the callback triggered once the data are available
  32172. * @param mimeType Defines the mime type of the result
  32173. */
  32174. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32175. /**
  32176. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32177. * @param successCallback defines the callback triggered once the data are available
  32178. * @param mimeType defines the mime type of the result
  32179. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32180. */
  32181. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32182. /**
  32183. * Downloads a blob in the browser
  32184. * @param blob defines the blob to download
  32185. * @param fileName defines the name of the downloaded file
  32186. */
  32187. static Download(blob: Blob, fileName: string): void;
  32188. /**
  32189. * Captures a screenshot of the current rendering
  32190. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32191. * @param engine defines the rendering engine
  32192. * @param camera defines the source camera
  32193. * @param size This parameter can be set to a single number or to an object with the
  32194. * following (optional) properties: precision, width, height. If a single number is passed,
  32195. * it will be used for both width and height. If an object is passed, the screenshot size
  32196. * will be derived from the parameters. The precision property is a multiplier allowing
  32197. * rendering at a higher or lower resolution
  32198. * @param successCallback defines the callback receives a single parameter which contains the
  32199. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32200. * src parameter of an <img> to display it
  32201. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32202. * Check your browser for supported MIME types
  32203. */
  32204. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  32205. /**
  32206. * Captures a screenshot of the current rendering
  32207. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32208. * @param engine defines the rendering engine
  32209. * @param camera defines the source camera
  32210. * @param size This parameter can be set to a single number or to an object with the
  32211. * following (optional) properties: precision, width, height. If a single number is passed,
  32212. * it will be used for both width and height. If an object is passed, the screenshot size
  32213. * will be derived from the parameters. The precision property is a multiplier allowing
  32214. * rendering at a higher or lower resolution
  32215. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32216. * Check your browser for supported MIME types
  32217. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32218. * to the src parameter of an <img> to display it
  32219. */
  32220. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  32221. /**
  32222. * Generates an image screenshot from the specified camera.
  32223. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32224. * @param engine The engine to use for rendering
  32225. * @param camera The camera to use for rendering
  32226. * @param size This parameter can be set to a single number or to an object with the
  32227. * following (optional) properties: precision, width, height. If a single number is passed,
  32228. * it will be used for both width and height. If an object is passed, the screenshot size
  32229. * will be derived from the parameters. The precision property is a multiplier allowing
  32230. * rendering at a higher or lower resolution
  32231. * @param successCallback The callback receives a single parameter which contains the
  32232. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32233. * src parameter of an <img> to display it
  32234. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32235. * Check your browser for supported MIME types
  32236. * @param samples Texture samples (default: 1)
  32237. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32238. * @param fileName A name for for the downloaded file.
  32239. */
  32240. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32241. /**
  32242. * Generates an image screenshot from the specified camera.
  32243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32244. * @param engine The engine to use for rendering
  32245. * @param camera The camera to use for rendering
  32246. * @param size This parameter can be set to a single number or to an object with the
  32247. * following (optional) properties: precision, width, height. If a single number is passed,
  32248. * it will be used for both width and height. If an object is passed, the screenshot size
  32249. * will be derived from the parameters. The precision property is a multiplier allowing
  32250. * rendering at a higher or lower resolution
  32251. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32252. * Check your browser for supported MIME types
  32253. * @param samples Texture samples (default: 1)
  32254. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32255. * @param fileName A name for for the downloaded file.
  32256. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32257. * to the src parameter of an <img> to display it
  32258. */
  32259. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32260. /**
  32261. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32262. * Be aware Math.random() could cause collisions, but:
  32263. * "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"
  32264. * @returns a pseudo random id
  32265. */
  32266. static RandomId(): string;
  32267. /**
  32268. * Test if the given uri is a base64 string
  32269. * @param uri The uri to test
  32270. * @return True if the uri is a base64 string or false otherwise
  32271. */
  32272. static IsBase64(uri: string): boolean;
  32273. /**
  32274. * Decode the given base64 uri.
  32275. * @param uri The uri to decode
  32276. * @return The decoded base64 data.
  32277. */
  32278. static DecodeBase64(uri: string): ArrayBuffer;
  32279. /**
  32280. * Gets the absolute url.
  32281. * @param url the input url
  32282. * @return the absolute url
  32283. */
  32284. static GetAbsoluteUrl(url: string): string;
  32285. /**
  32286. * No log
  32287. */
  32288. static readonly NoneLogLevel: number;
  32289. /**
  32290. * Only message logs
  32291. */
  32292. static readonly MessageLogLevel: number;
  32293. /**
  32294. * Only warning logs
  32295. */
  32296. static readonly WarningLogLevel: number;
  32297. /**
  32298. * Only error logs
  32299. */
  32300. static readonly ErrorLogLevel: number;
  32301. /**
  32302. * All logs
  32303. */
  32304. static readonly AllLogLevel: number;
  32305. /**
  32306. * Gets a value indicating the number of loading errors
  32307. * @ignorenaming
  32308. */
  32309. static readonly errorsCount: number;
  32310. /**
  32311. * Callback called when a new log is added
  32312. */
  32313. static OnNewCacheEntry: (entry: string) => void;
  32314. /**
  32315. * Log a message to the console
  32316. * @param message defines the message to log
  32317. */
  32318. static Log(message: string): void;
  32319. /**
  32320. * Write a warning message to the console
  32321. * @param message defines the message to log
  32322. */
  32323. static Warn(message: string): void;
  32324. /**
  32325. * Write an error message to the console
  32326. * @param message defines the message to log
  32327. */
  32328. static Error(message: string): void;
  32329. /**
  32330. * Gets current log cache (list of logs)
  32331. */
  32332. static readonly LogCache: string;
  32333. /**
  32334. * Clears the log cache
  32335. */
  32336. static ClearLogCache(): void;
  32337. /**
  32338. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32339. */
  32340. static LogLevels: number;
  32341. /**
  32342. * Checks if the window object exists
  32343. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32344. */
  32345. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32346. /**
  32347. * No performance log
  32348. */
  32349. static readonly PerformanceNoneLogLevel: number;
  32350. /**
  32351. * Use user marks to log performance
  32352. */
  32353. static readonly PerformanceUserMarkLogLevel: number;
  32354. /**
  32355. * Log performance to the console
  32356. */
  32357. static readonly PerformanceConsoleLogLevel: number;
  32358. private static _performance;
  32359. /**
  32360. * Sets the current performance log level
  32361. */
  32362. static PerformanceLogLevel: number;
  32363. private static _StartPerformanceCounterDisabled;
  32364. private static _EndPerformanceCounterDisabled;
  32365. private static _StartUserMark;
  32366. private static _EndUserMark;
  32367. private static _StartPerformanceConsole;
  32368. private static _EndPerformanceConsole;
  32369. /**
  32370. * Starts a performance counter
  32371. */
  32372. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32373. /**
  32374. * Ends a specific performance coutner
  32375. */
  32376. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32377. /**
  32378. * Gets either window.performance.now() if supported or Date.now() else
  32379. */
  32380. static readonly Now: number;
  32381. /**
  32382. * This method will return the name of the class used to create the instance of the given object.
  32383. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32384. * @param object the object to get the class name from
  32385. * @param isType defines if the object is actually a type
  32386. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32387. */
  32388. static GetClassName(object: any, isType?: boolean): string;
  32389. /**
  32390. * Gets the first element of an array satisfying a given predicate
  32391. * @param array defines the array to browse
  32392. * @param predicate defines the predicate to use
  32393. * @returns null if not found or the element
  32394. */
  32395. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32396. /**
  32397. * This method will return the name of the full name of the class, including its owning module (if any).
  32398. * 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).
  32399. * @param object the object to get the class name from
  32400. * @param isType defines if the object is actually a type
  32401. * @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.
  32402. * @ignorenaming
  32403. */
  32404. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32405. /**
  32406. * Returns a promise that resolves after the given amount of time.
  32407. * @param delay Number of milliseconds to delay
  32408. * @returns Promise that resolves after the given amount of time
  32409. */
  32410. static DelayAsync(delay: number): Promise<void>;
  32411. }
  32412. /**
  32413. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32414. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32415. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32416. * @param name The name of the class, case should be preserved
  32417. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32418. */
  32419. export function className(name: string, module?: string): (target: Object) => void;
  32420. /**
  32421. * An implementation of a loop for asynchronous functions.
  32422. */
  32423. export class AsyncLoop {
  32424. /**
  32425. * Defines the number of iterations for the loop
  32426. */
  32427. iterations: number;
  32428. /**
  32429. * Defines the current index of the loop.
  32430. */
  32431. index: number;
  32432. private _done;
  32433. private _fn;
  32434. private _successCallback;
  32435. /**
  32436. * Constructor.
  32437. * @param iterations the number of iterations.
  32438. * @param func the function to run each iteration
  32439. * @param successCallback the callback that will be called upon succesful execution
  32440. * @param offset starting offset.
  32441. */
  32442. constructor(
  32443. /**
  32444. * Defines the number of iterations for the loop
  32445. */
  32446. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32447. /**
  32448. * Execute the next iteration. Must be called after the last iteration was finished.
  32449. */
  32450. executeNext(): void;
  32451. /**
  32452. * Break the loop and run the success callback.
  32453. */
  32454. breakLoop(): void;
  32455. /**
  32456. * Create and run an async loop.
  32457. * @param iterations the number of iterations.
  32458. * @param fn the function to run each iteration
  32459. * @param successCallback the callback that will be called upon succesful execution
  32460. * @param offset starting offset.
  32461. * @returns the created async loop object
  32462. */
  32463. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32464. /**
  32465. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32466. * @param iterations total number of iterations
  32467. * @param syncedIterations number of synchronous iterations in each async iteration.
  32468. * @param fn the function to call each iteration.
  32469. * @param callback a success call back that will be called when iterating stops.
  32470. * @param breakFunction a break condition (optional)
  32471. * @param timeout timeout settings for the setTimeout function. default - 0.
  32472. * @returns the created async loop object
  32473. */
  32474. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32475. }
  32476. }
  32477. declare module BABYLON {
  32478. /**
  32479. * This class implement a typical dictionary using a string as key and the generic type T as value.
  32480. * The underlying implementation relies on an associative array to ensure the best performances.
  32481. * The value can be anything including 'null' but except 'undefined'
  32482. */
  32483. export class StringDictionary<T> {
  32484. /**
  32485. * This will clear this dictionary and copy the content from the 'source' one.
  32486. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  32487. * @param source the dictionary to take the content from and copy to this dictionary
  32488. */
  32489. copyFrom(source: StringDictionary<T>): void;
  32490. /**
  32491. * Get a value based from its key
  32492. * @param key the given key to get the matching value from
  32493. * @return the value if found, otherwise undefined is returned
  32494. */
  32495. get(key: string): T | undefined;
  32496. /**
  32497. * Get a value from its key or add it if it doesn't exist.
  32498. * This method will ensure you that a given key/data will be present in the dictionary.
  32499. * @param key the given key to get the matching value from
  32500. * @param factory the factory that will create the value if the key is not present in the dictionary.
  32501. * The factory will only be invoked if there's no data for the given key.
  32502. * @return the value corresponding to the key.
  32503. */
  32504. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  32505. /**
  32506. * Get a value from its key if present in the dictionary otherwise add it
  32507. * @param key the key to get the value from
  32508. * @param val if there's no such key/value pair in the dictionary add it with this value
  32509. * @return the value corresponding to the key
  32510. */
  32511. getOrAdd(key: string, val: T): T;
  32512. /**
  32513. * Check if there's a given key in the dictionary
  32514. * @param key the key to check for
  32515. * @return true if the key is present, false otherwise
  32516. */
  32517. contains(key: string): boolean;
  32518. /**
  32519. * Add a new key and its corresponding value
  32520. * @param key the key to add
  32521. * @param value the value corresponding to the key
  32522. * @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
  32523. */
  32524. add(key: string, value: T): boolean;
  32525. /**
  32526. * Update a specific value associated to a key
  32527. * @param key defines the key to use
  32528. * @param value defines the value to store
  32529. * @returns true if the value was updated (or false if the key was not found)
  32530. */
  32531. set(key: string, value: T): boolean;
  32532. /**
  32533. * Get the element of the given key and remove it from the dictionary
  32534. * @param key defines the key to search
  32535. * @returns the value associated with the key or null if not found
  32536. */
  32537. getAndRemove(key: string): Nullable<T>;
  32538. /**
  32539. * Remove a key/value from the dictionary.
  32540. * @param key the key to remove
  32541. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  32542. */
  32543. remove(key: string): boolean;
  32544. /**
  32545. * Clear the whole content of the dictionary
  32546. */
  32547. clear(): void;
  32548. /**
  32549. * Gets the current count
  32550. */
  32551. readonly count: number;
  32552. /**
  32553. * Execute a callback on each key/val of the dictionary.
  32554. * Note that you can remove any element in this dictionary in the callback implementation
  32555. * @param callback the callback to execute on a given key/value pair
  32556. */
  32557. forEach(callback: (key: string, val: T) => void): void;
  32558. /**
  32559. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  32560. * If the callback returns null or undefined the method will iterate to the next key/value pair
  32561. * Note that you can remove any element in this dictionary in the callback implementation
  32562. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  32563. * @returns the first item
  32564. */
  32565. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  32566. private _count;
  32567. private _data;
  32568. }
  32569. }
  32570. declare module BABYLON {
  32571. /** @hidden */
  32572. export interface ICollisionCoordinator {
  32573. createCollider(): Collider;
  32574. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32575. init(scene: Scene): void;
  32576. }
  32577. /** @hidden */
  32578. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32579. private _scene;
  32580. private _scaledPosition;
  32581. private _scaledVelocity;
  32582. private _finalPosition;
  32583. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32584. createCollider(): Collider;
  32585. init(scene: Scene): void;
  32586. private _collideWithWorld;
  32587. }
  32588. }
  32589. declare module BABYLON {
  32590. /**
  32591. * Class used to manage all inputs for the scene.
  32592. */
  32593. export class InputManager {
  32594. /** The distance in pixel that you have to move to prevent some events */
  32595. static DragMovementThreshold: number;
  32596. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32597. static LongPressDelay: number;
  32598. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32599. static DoubleClickDelay: number;
  32600. /** If you need to check double click without raising a single click at first click, enable this flag */
  32601. static ExclusiveDoubleClickMode: boolean;
  32602. private _wheelEventName;
  32603. private _onPointerMove;
  32604. private _onPointerDown;
  32605. private _onPointerUp;
  32606. private _initClickEvent;
  32607. private _initActionManager;
  32608. private _delayedSimpleClick;
  32609. private _delayedSimpleClickTimeout;
  32610. private _previousDelayedSimpleClickTimeout;
  32611. private _meshPickProceed;
  32612. private _previousButtonPressed;
  32613. private _currentPickResult;
  32614. private _previousPickResult;
  32615. private _totalPointersPressed;
  32616. private _doubleClickOccured;
  32617. private _pointerOverMesh;
  32618. private _pickedDownMesh;
  32619. private _pickedUpMesh;
  32620. private _pointerX;
  32621. private _pointerY;
  32622. private _unTranslatedPointerX;
  32623. private _unTranslatedPointerY;
  32624. private _startingPointerPosition;
  32625. private _previousStartingPointerPosition;
  32626. private _startingPointerTime;
  32627. private _previousStartingPointerTime;
  32628. private _pointerCaptures;
  32629. private _onKeyDown;
  32630. private _onKeyUp;
  32631. private _onCanvasFocusObserver;
  32632. private _onCanvasBlurObserver;
  32633. private _scene;
  32634. /**
  32635. * Creates a new InputManager
  32636. * @param scene defines the hosting scene
  32637. */
  32638. constructor(scene: Scene);
  32639. /**
  32640. * Gets the mesh that is currently under the pointer
  32641. */
  32642. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32643. /**
  32644. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32645. */
  32646. readonly unTranslatedPointer: Vector2;
  32647. /**
  32648. * Gets or sets the current on-screen X position of the pointer
  32649. */
  32650. pointerX: number;
  32651. /**
  32652. * Gets or sets the current on-screen Y position of the pointer
  32653. */
  32654. pointerY: number;
  32655. private _updatePointerPosition;
  32656. private _processPointerMove;
  32657. private _setRayOnPointerInfo;
  32658. private _checkPrePointerObservable;
  32659. /**
  32660. * Use this method to simulate a pointer move on a mesh
  32661. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32662. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32663. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32664. */
  32665. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32666. /**
  32667. * Use this method to simulate a pointer down on a mesh
  32668. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32669. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32670. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32671. */
  32672. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32673. private _processPointerDown;
  32674. /** @hidden */
  32675. _isPointerSwiping(): boolean;
  32676. /**
  32677. * Use this method to simulate a pointer up on a mesh
  32678. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32679. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32680. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32681. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32682. */
  32683. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32684. private _processPointerUp;
  32685. /**
  32686. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32687. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32688. * @returns true if the pointer was captured
  32689. */
  32690. isPointerCaptured(pointerId?: number): boolean;
  32691. /**
  32692. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32693. * @param attachUp defines if you want to attach events to pointerup
  32694. * @param attachDown defines if you want to attach events to pointerdown
  32695. * @param attachMove defines if you want to attach events to pointermove
  32696. */
  32697. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32698. /**
  32699. * Detaches all event handlers
  32700. */
  32701. detachControl(): void;
  32702. /**
  32703. * Force the value of meshUnderPointer
  32704. * @param mesh defines the mesh to use
  32705. */
  32706. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32707. /**
  32708. * Gets the mesh under the pointer
  32709. * @returns a Mesh or null if no mesh is under the pointer
  32710. */
  32711. getPointerOverMesh(): Nullable<AbstractMesh>;
  32712. }
  32713. }
  32714. declare module BABYLON {
  32715. /**
  32716. * Helper class used to generate session unique ID
  32717. */
  32718. export class UniqueIdGenerator {
  32719. private static _UniqueIdCounter;
  32720. /**
  32721. * Gets an unique (relatively to the current scene) Id
  32722. */
  32723. static readonly UniqueId: number;
  32724. }
  32725. }
  32726. declare module BABYLON {
  32727. /**
  32728. * This class defines the direct association between an animation and a target
  32729. */
  32730. export class TargetedAnimation {
  32731. /**
  32732. * Animation to perform
  32733. */
  32734. animation: Animation;
  32735. /**
  32736. * Target to animate
  32737. */
  32738. target: any;
  32739. /**
  32740. * Serialize the object
  32741. * @returns the JSON object representing the current entity
  32742. */
  32743. serialize(): any;
  32744. }
  32745. /**
  32746. * Use this class to create coordinated animations on multiple targets
  32747. */
  32748. export class AnimationGroup implements IDisposable {
  32749. /** The name of the animation group */
  32750. name: string;
  32751. private _scene;
  32752. private _targetedAnimations;
  32753. private _animatables;
  32754. private _from;
  32755. private _to;
  32756. private _isStarted;
  32757. private _isPaused;
  32758. private _speedRatio;
  32759. private _loopAnimation;
  32760. /**
  32761. * Gets or sets the unique id of the node
  32762. */
  32763. uniqueId: number;
  32764. /**
  32765. * This observable will notify when one animation have ended
  32766. */
  32767. onAnimationEndObservable: Observable<TargetedAnimation>;
  32768. /**
  32769. * Observer raised when one animation loops
  32770. */
  32771. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32772. /**
  32773. * This observable will notify when all animations have ended.
  32774. */
  32775. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32776. /**
  32777. * This observable will notify when all animations have paused.
  32778. */
  32779. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32780. /**
  32781. * This observable will notify when all animations are playing.
  32782. */
  32783. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32784. /**
  32785. * Gets the first frame
  32786. */
  32787. readonly from: number;
  32788. /**
  32789. * Gets the last frame
  32790. */
  32791. readonly to: number;
  32792. /**
  32793. * Define if the animations are started
  32794. */
  32795. readonly isStarted: boolean;
  32796. /**
  32797. * Gets a value indicating that the current group is playing
  32798. */
  32799. readonly isPlaying: boolean;
  32800. /**
  32801. * Gets or sets the speed ratio to use for all animations
  32802. */
  32803. /**
  32804. * Gets or sets the speed ratio to use for all animations
  32805. */
  32806. speedRatio: number;
  32807. /**
  32808. * Gets or sets if all animations should loop or not
  32809. */
  32810. loopAnimation: boolean;
  32811. /**
  32812. * Gets the targeted animations for this animation group
  32813. */
  32814. readonly targetedAnimations: Array<TargetedAnimation>;
  32815. /**
  32816. * returning the list of animatables controlled by this animation group.
  32817. */
  32818. readonly animatables: Array<Animatable>;
  32819. /**
  32820. * Instantiates a new Animation Group.
  32821. * This helps managing several animations at once.
  32822. * @see http://doc.babylonjs.com/how_to/group
  32823. * @param name Defines the name of the group
  32824. * @param scene Defines the scene the group belongs to
  32825. */
  32826. constructor(
  32827. /** The name of the animation group */
  32828. name: string, scene?: Nullable<Scene>);
  32829. /**
  32830. * Add an animation (with its target) in the group
  32831. * @param animation defines the animation we want to add
  32832. * @param target defines the target of the animation
  32833. * @returns the TargetedAnimation object
  32834. */
  32835. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32836. /**
  32837. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32838. * It can add constant keys at begin or end
  32839. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32840. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32841. * @returns the animation group
  32842. */
  32843. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32844. /**
  32845. * Start all animations on given targets
  32846. * @param loop defines if animations must loop
  32847. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32848. * @param from defines the from key (optional)
  32849. * @param to defines the to key (optional)
  32850. * @returns the current animation group
  32851. */
  32852. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32853. /**
  32854. * Pause all animations
  32855. * @returns the animation group
  32856. */
  32857. pause(): AnimationGroup;
  32858. /**
  32859. * Play all animations to initial state
  32860. * This function will start() the animations if they were not started or will restart() them if they were paused
  32861. * @param loop defines if animations must loop
  32862. * @returns the animation group
  32863. */
  32864. play(loop?: boolean): AnimationGroup;
  32865. /**
  32866. * Reset all animations to initial state
  32867. * @returns the animation group
  32868. */
  32869. reset(): AnimationGroup;
  32870. /**
  32871. * Restart animations from key 0
  32872. * @returns the animation group
  32873. */
  32874. restart(): AnimationGroup;
  32875. /**
  32876. * Stop all animations
  32877. * @returns the animation group
  32878. */
  32879. stop(): AnimationGroup;
  32880. /**
  32881. * Set animation weight for all animatables
  32882. * @param weight defines the weight to use
  32883. * @return the animationGroup
  32884. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32885. */
  32886. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32887. /**
  32888. * Synchronize and normalize all animatables with a source animatable
  32889. * @param root defines the root animatable to synchronize with
  32890. * @return the animationGroup
  32891. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32892. */
  32893. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32894. /**
  32895. * Goes to a specific frame in this animation group
  32896. * @param frame the frame number to go to
  32897. * @return the animationGroup
  32898. */
  32899. goToFrame(frame: number): AnimationGroup;
  32900. /**
  32901. * Dispose all associated resources
  32902. */
  32903. dispose(): void;
  32904. private _checkAnimationGroupEnded;
  32905. /**
  32906. * Clone the current animation group and returns a copy
  32907. * @param newName defines the name of the new group
  32908. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32909. * @returns the new aniamtion group
  32910. */
  32911. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32912. /**
  32913. * Serializes the animationGroup to an object
  32914. * @returns Serialized object
  32915. */
  32916. serialize(): any;
  32917. /**
  32918. * Returns a new AnimationGroup object parsed from the source provided.
  32919. * @param parsedAnimationGroup defines the source
  32920. * @param scene defines the scene that will receive the animationGroup
  32921. * @returns a new AnimationGroup
  32922. */
  32923. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32924. /**
  32925. * Returns the string "AnimationGroup"
  32926. * @returns "AnimationGroup"
  32927. */
  32928. getClassName(): string;
  32929. /**
  32930. * Creates a detailled string about the object
  32931. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32932. * @returns a string representing the object
  32933. */
  32934. toString(fullDetails?: boolean): string;
  32935. }
  32936. }
  32937. declare module BABYLON {
  32938. /**
  32939. * Define an interface for all classes that will hold resources
  32940. */
  32941. export interface IDisposable {
  32942. /**
  32943. * Releases all held resources
  32944. */
  32945. dispose(): void;
  32946. }
  32947. /** Interface defining initialization parameters for Scene class */
  32948. export interface SceneOptions {
  32949. /**
  32950. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32951. * It will improve performance when the number of geometries becomes important.
  32952. */
  32953. useGeometryUniqueIdsMap?: boolean;
  32954. /**
  32955. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32956. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32957. */
  32958. useMaterialMeshMap?: boolean;
  32959. /**
  32960. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32961. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32962. */
  32963. useClonedMeshhMap?: boolean;
  32964. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32965. virtual?: boolean;
  32966. }
  32967. /**
  32968. * Represents a scene to be rendered by the engine.
  32969. * @see http://doc.babylonjs.com/features/scene
  32970. */
  32971. export class Scene extends AbstractScene implements IAnimatable {
  32972. /** The fog is deactivated */
  32973. static readonly FOGMODE_NONE: number;
  32974. /** The fog density is following an exponential function */
  32975. static readonly FOGMODE_EXP: number;
  32976. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32977. static readonly FOGMODE_EXP2: number;
  32978. /** The fog density is following a linear function. */
  32979. static readonly FOGMODE_LINEAR: number;
  32980. /**
  32981. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32982. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32983. */
  32984. static MinDeltaTime: number;
  32985. /**
  32986. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32988. */
  32989. static MaxDeltaTime: number;
  32990. /**
  32991. * Factory used to create the default material.
  32992. * @param name The name of the material to create
  32993. * @param scene The scene to create the material for
  32994. * @returns The default material
  32995. */
  32996. static DefaultMaterialFactory(scene: Scene): Material;
  32997. /**
  32998. * Factory used to create the a collision coordinator.
  32999. * @returns The collision coordinator
  33000. */
  33001. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33002. /** @hidden */
  33003. _inputManager: InputManager;
  33004. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33005. cameraToUseForPointers: Nullable<Camera>;
  33006. /** @hidden */
  33007. readonly _isScene: boolean;
  33008. /**
  33009. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33010. */
  33011. autoClear: boolean;
  33012. /**
  33013. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33014. */
  33015. autoClearDepthAndStencil: boolean;
  33016. /**
  33017. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33018. */
  33019. clearColor: Color4;
  33020. /**
  33021. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33022. */
  33023. ambientColor: Color3;
  33024. /**
  33025. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33026. * It should only be one of the following (if not the default embedded one):
  33027. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33028. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33029. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33030. * The material properties need to be setup according to the type of texture in use.
  33031. */
  33032. environmentBRDFTexture: BaseTexture;
  33033. /** @hidden */
  33034. protected _environmentTexture: Nullable<BaseTexture>;
  33035. /**
  33036. * Texture used in all pbr material as the reflection texture.
  33037. * As in the majority of the scene they are the same (exception for multi room and so on),
  33038. * this is easier to reference from here than from all the materials.
  33039. */
  33040. /**
  33041. * Texture used in all pbr material as the reflection texture.
  33042. * As in the majority of the scene they are the same (exception for multi room and so on),
  33043. * this is easier to set here than in all the materials.
  33044. */
  33045. environmentTexture: Nullable<BaseTexture>;
  33046. /** @hidden */
  33047. protected _environmentIntensity: number;
  33048. /**
  33049. * Intensity of the environment in all pbr material.
  33050. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33051. * As in the majority of the scene they are the same (exception for multi room and so on),
  33052. * this is easier to reference from here than from all the materials.
  33053. */
  33054. /**
  33055. * Intensity of the environment in all pbr material.
  33056. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33057. * As in the majority of the scene they are the same (exception for multi room and so on),
  33058. * this is easier to set here than in all the materials.
  33059. */
  33060. environmentIntensity: number;
  33061. /** @hidden */
  33062. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33063. /**
  33064. * Default image processing configuration used either in the rendering
  33065. * Forward main pass or through the imageProcessingPostProcess if present.
  33066. * As in the majority of the scene they are the same (exception for multi camera),
  33067. * this is easier to reference from here than from all the materials and post process.
  33068. *
  33069. * No setter as we it is a shared configuration, you can set the values instead.
  33070. */
  33071. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33072. private _forceWireframe;
  33073. /**
  33074. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33075. */
  33076. forceWireframe: boolean;
  33077. private _forcePointsCloud;
  33078. /**
  33079. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33080. */
  33081. forcePointsCloud: boolean;
  33082. /**
  33083. * Gets or sets the active clipplane 1
  33084. */
  33085. clipPlane: Nullable<Plane>;
  33086. /**
  33087. * Gets or sets the active clipplane 2
  33088. */
  33089. clipPlane2: Nullable<Plane>;
  33090. /**
  33091. * Gets or sets the active clipplane 3
  33092. */
  33093. clipPlane3: Nullable<Plane>;
  33094. /**
  33095. * Gets or sets the active clipplane 4
  33096. */
  33097. clipPlane4: Nullable<Plane>;
  33098. /**
  33099. * Gets or sets a boolean indicating if animations are enabled
  33100. */
  33101. animationsEnabled: boolean;
  33102. private _animationPropertiesOverride;
  33103. /**
  33104. * Gets or sets the animation properties override
  33105. */
  33106. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33107. /**
  33108. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33109. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33110. */
  33111. useConstantAnimationDeltaTime: boolean;
  33112. /**
  33113. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33114. * Please note that it requires to run a ray cast through the scene on every frame
  33115. */
  33116. constantlyUpdateMeshUnderPointer: boolean;
  33117. /**
  33118. * Defines the HTML cursor to use when hovering over interactive elements
  33119. */
  33120. hoverCursor: string;
  33121. /**
  33122. * Defines the HTML default cursor to use (empty by default)
  33123. */
  33124. defaultCursor: string;
  33125. /**
  33126. * This is used to call preventDefault() on pointer down
  33127. * in order to block unwanted artifacts like system double clicks
  33128. */
  33129. preventDefaultOnPointerDown: boolean;
  33130. /**
  33131. * This is used to call preventDefault() on pointer up
  33132. * in order to block unwanted artifacts like system double clicks
  33133. */
  33134. preventDefaultOnPointerUp: boolean;
  33135. /**
  33136. * Gets or sets user defined metadata
  33137. */
  33138. metadata: any;
  33139. /**
  33140. * For internal use only. Please do not use.
  33141. */
  33142. reservedDataStore: any;
  33143. /**
  33144. * Gets the name of the plugin used to load this scene (null by default)
  33145. */
  33146. loadingPluginName: string;
  33147. /**
  33148. * Use this array to add regular expressions used to disable offline support for specific urls
  33149. */
  33150. disableOfflineSupportExceptionRules: RegExp[];
  33151. /**
  33152. * An event triggered when the scene is disposed.
  33153. */
  33154. onDisposeObservable: Observable<Scene>;
  33155. private _onDisposeObserver;
  33156. /** Sets a function to be executed when this scene is disposed. */
  33157. onDispose: () => void;
  33158. /**
  33159. * An event triggered before rendering the scene (right after animations and physics)
  33160. */
  33161. onBeforeRenderObservable: Observable<Scene>;
  33162. private _onBeforeRenderObserver;
  33163. /** Sets a function to be executed before rendering this scene */
  33164. beforeRender: Nullable<() => void>;
  33165. /**
  33166. * An event triggered after rendering the scene
  33167. */
  33168. onAfterRenderObservable: Observable<Scene>;
  33169. /**
  33170. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33171. */
  33172. onAfterRenderCameraObservable: Observable<Camera>;
  33173. private _onAfterRenderObserver;
  33174. /** Sets a function to be executed after rendering this scene */
  33175. afterRender: Nullable<() => void>;
  33176. /**
  33177. * An event triggered before animating the scene
  33178. */
  33179. onBeforeAnimationsObservable: Observable<Scene>;
  33180. /**
  33181. * An event triggered after animations processing
  33182. */
  33183. onAfterAnimationsObservable: Observable<Scene>;
  33184. /**
  33185. * An event triggered before draw calls are ready to be sent
  33186. */
  33187. onBeforeDrawPhaseObservable: Observable<Scene>;
  33188. /**
  33189. * An event triggered after draw calls have been sent
  33190. */
  33191. onAfterDrawPhaseObservable: Observable<Scene>;
  33192. /**
  33193. * An event triggered when the scene is ready
  33194. */
  33195. onReadyObservable: Observable<Scene>;
  33196. /**
  33197. * An event triggered before rendering a camera
  33198. */
  33199. onBeforeCameraRenderObservable: Observable<Camera>;
  33200. private _onBeforeCameraRenderObserver;
  33201. /** Sets a function to be executed before rendering a camera*/
  33202. beforeCameraRender: () => void;
  33203. /**
  33204. * An event triggered after rendering a camera
  33205. */
  33206. onAfterCameraRenderObservable: Observable<Camera>;
  33207. private _onAfterCameraRenderObserver;
  33208. /** Sets a function to be executed after rendering a camera*/
  33209. afterCameraRender: () => void;
  33210. /**
  33211. * An event triggered when active meshes evaluation is about to start
  33212. */
  33213. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33214. /**
  33215. * An event triggered when active meshes evaluation is done
  33216. */
  33217. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33218. /**
  33219. * An event triggered when particles rendering is about to start
  33220. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33221. */
  33222. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33223. /**
  33224. * An event triggered when particles rendering is done
  33225. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33226. */
  33227. onAfterParticlesRenderingObservable: Observable<Scene>;
  33228. /**
  33229. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33230. */
  33231. onDataLoadedObservable: Observable<Scene>;
  33232. /**
  33233. * An event triggered when a camera is created
  33234. */
  33235. onNewCameraAddedObservable: Observable<Camera>;
  33236. /**
  33237. * An event triggered when a camera is removed
  33238. */
  33239. onCameraRemovedObservable: Observable<Camera>;
  33240. /**
  33241. * An event triggered when a light is created
  33242. */
  33243. onNewLightAddedObservable: Observable<Light>;
  33244. /**
  33245. * An event triggered when a light is removed
  33246. */
  33247. onLightRemovedObservable: Observable<Light>;
  33248. /**
  33249. * An event triggered when a geometry is created
  33250. */
  33251. onNewGeometryAddedObservable: Observable<Geometry>;
  33252. /**
  33253. * An event triggered when a geometry is removed
  33254. */
  33255. onGeometryRemovedObservable: Observable<Geometry>;
  33256. /**
  33257. * An event triggered when a transform node is created
  33258. */
  33259. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33260. /**
  33261. * An event triggered when a transform node is removed
  33262. */
  33263. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33264. /**
  33265. * An event triggered when a mesh is created
  33266. */
  33267. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33268. /**
  33269. * An event triggered when a mesh is removed
  33270. */
  33271. onMeshRemovedObservable: Observable<AbstractMesh>;
  33272. /**
  33273. * An event triggered when a skeleton is created
  33274. */
  33275. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33276. /**
  33277. * An event triggered when a skeleton is removed
  33278. */
  33279. onSkeletonRemovedObservable: Observable<Skeleton>;
  33280. /**
  33281. * An event triggered when a material is created
  33282. */
  33283. onNewMaterialAddedObservable: Observable<Material>;
  33284. /**
  33285. * An event triggered when a material is removed
  33286. */
  33287. onMaterialRemovedObservable: Observable<Material>;
  33288. /**
  33289. * An event triggered when a texture is created
  33290. */
  33291. onNewTextureAddedObservable: Observable<BaseTexture>;
  33292. /**
  33293. * An event triggered when a texture is removed
  33294. */
  33295. onTextureRemovedObservable: Observable<BaseTexture>;
  33296. /**
  33297. * An event triggered when render targets are about to be rendered
  33298. * Can happen multiple times per frame.
  33299. */
  33300. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33301. /**
  33302. * An event triggered when render targets were rendered.
  33303. * Can happen multiple times per frame.
  33304. */
  33305. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33306. /**
  33307. * An event triggered before calculating deterministic simulation step
  33308. */
  33309. onBeforeStepObservable: Observable<Scene>;
  33310. /**
  33311. * An event triggered after calculating deterministic simulation step
  33312. */
  33313. onAfterStepObservable: Observable<Scene>;
  33314. /**
  33315. * An event triggered when the activeCamera property is updated
  33316. */
  33317. onActiveCameraChanged: Observable<Scene>;
  33318. /**
  33319. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33320. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33321. * 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)
  33322. */
  33323. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33324. /**
  33325. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33326. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33327. * 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)
  33328. */
  33329. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33330. /**
  33331. * This Observable will when a mesh has been imported into the scene.
  33332. */
  33333. onMeshImportedObservable: Observable<AbstractMesh>;
  33334. /**
  33335. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33336. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33337. */
  33338. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33339. /** @hidden */
  33340. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33341. /**
  33342. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33343. */
  33344. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33345. /**
  33346. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33347. */
  33348. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33349. /**
  33350. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33351. */
  33352. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33353. /** Callback called when a pointer move is detected */
  33354. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33355. /** Callback called when a pointer down is detected */
  33356. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33357. /** Callback called when a pointer up is detected */
  33358. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33359. /** Callback called when a pointer pick is detected */
  33360. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33361. /**
  33362. * 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).
  33363. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33364. */
  33365. onPrePointerObservable: Observable<PointerInfoPre>;
  33366. /**
  33367. * Observable event triggered each time an input event is received from the rendering canvas
  33368. */
  33369. onPointerObservable: Observable<PointerInfo>;
  33370. /**
  33371. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33372. */
  33373. readonly unTranslatedPointer: Vector2;
  33374. /**
  33375. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33376. */
  33377. static DragMovementThreshold: number;
  33378. /**
  33379. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33380. */
  33381. static LongPressDelay: number;
  33382. /**
  33383. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33384. */
  33385. static DoubleClickDelay: number;
  33386. /** If you need to check double click without raising a single click at first click, enable this flag */
  33387. static ExclusiveDoubleClickMode: boolean;
  33388. /** @hidden */
  33389. _mirroredCameraPosition: Nullable<Vector3>;
  33390. /**
  33391. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33392. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33393. */
  33394. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33395. /**
  33396. * Observable event triggered each time an keyboard event is received from the hosting window
  33397. */
  33398. onKeyboardObservable: Observable<KeyboardInfo>;
  33399. private _useRightHandedSystem;
  33400. /**
  33401. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33402. */
  33403. useRightHandedSystem: boolean;
  33404. private _timeAccumulator;
  33405. private _currentStepId;
  33406. private _currentInternalStep;
  33407. /**
  33408. * Sets the step Id used by deterministic lock step
  33409. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33410. * @param newStepId defines the step Id
  33411. */
  33412. setStepId(newStepId: number): void;
  33413. /**
  33414. * Gets the step Id used by deterministic lock step
  33415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33416. * @returns the step Id
  33417. */
  33418. getStepId(): number;
  33419. /**
  33420. * Gets the internal step used by deterministic lock step
  33421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33422. * @returns the internal step
  33423. */
  33424. getInternalStep(): number;
  33425. private _fogEnabled;
  33426. /**
  33427. * Gets or sets a boolean indicating if fog is enabled on this scene
  33428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33429. * (Default is true)
  33430. */
  33431. fogEnabled: boolean;
  33432. private _fogMode;
  33433. /**
  33434. * Gets or sets the fog mode to use
  33435. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33436. * | mode | value |
  33437. * | --- | --- |
  33438. * | FOGMODE_NONE | 0 |
  33439. * | FOGMODE_EXP | 1 |
  33440. * | FOGMODE_EXP2 | 2 |
  33441. * | FOGMODE_LINEAR | 3 |
  33442. */
  33443. fogMode: number;
  33444. /**
  33445. * Gets or sets the fog color to use
  33446. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33447. * (Default is Color3(0.2, 0.2, 0.3))
  33448. */
  33449. fogColor: Color3;
  33450. /**
  33451. * Gets or sets the fog density to use
  33452. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33453. * (Default is 0.1)
  33454. */
  33455. fogDensity: number;
  33456. /**
  33457. * Gets or sets the fog start distance to use
  33458. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33459. * (Default is 0)
  33460. */
  33461. fogStart: number;
  33462. /**
  33463. * Gets or sets the fog end distance to use
  33464. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33465. * (Default is 1000)
  33466. */
  33467. fogEnd: number;
  33468. private _shadowsEnabled;
  33469. /**
  33470. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33471. */
  33472. shadowsEnabled: boolean;
  33473. private _lightsEnabled;
  33474. /**
  33475. * Gets or sets a boolean indicating if lights are enabled on this scene
  33476. */
  33477. lightsEnabled: boolean;
  33478. /** All of the active cameras added to this scene. */
  33479. activeCameras: Camera[];
  33480. /** @hidden */
  33481. _activeCamera: Nullable<Camera>;
  33482. /** Gets or sets the current active camera */
  33483. activeCamera: Nullable<Camera>;
  33484. private _defaultMaterial;
  33485. /** The default material used on meshes when no material is affected */
  33486. /** The default material used on meshes when no material is affected */
  33487. defaultMaterial: Material;
  33488. private _texturesEnabled;
  33489. /**
  33490. * Gets or sets a boolean indicating if textures are enabled on this scene
  33491. */
  33492. texturesEnabled: boolean;
  33493. /**
  33494. * Gets or sets a boolean indicating if particles are enabled on this scene
  33495. */
  33496. particlesEnabled: boolean;
  33497. /**
  33498. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33499. */
  33500. spritesEnabled: boolean;
  33501. private _skeletonsEnabled;
  33502. /**
  33503. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33504. */
  33505. skeletonsEnabled: boolean;
  33506. /**
  33507. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33508. */
  33509. lensFlaresEnabled: boolean;
  33510. /**
  33511. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33512. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33513. */
  33514. collisionsEnabled: boolean;
  33515. private _collisionCoordinator;
  33516. /** @hidden */
  33517. readonly collisionCoordinator: ICollisionCoordinator;
  33518. /**
  33519. * Defines the gravity applied to this scene (used only for collisions)
  33520. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33521. */
  33522. gravity: Vector3;
  33523. /**
  33524. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33525. */
  33526. postProcessesEnabled: boolean;
  33527. /**
  33528. * The list of postprocesses added to the scene
  33529. */
  33530. postProcesses: PostProcess[];
  33531. /**
  33532. * Gets the current postprocess manager
  33533. */
  33534. postProcessManager: PostProcessManager;
  33535. /**
  33536. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33537. */
  33538. renderTargetsEnabled: boolean;
  33539. /**
  33540. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33541. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33542. */
  33543. dumpNextRenderTargets: boolean;
  33544. /**
  33545. * The list of user defined render targets added to the scene
  33546. */
  33547. customRenderTargets: RenderTargetTexture[];
  33548. /**
  33549. * Defines if texture loading must be delayed
  33550. * If true, textures will only be loaded when they need to be rendered
  33551. */
  33552. useDelayedTextureLoading: boolean;
  33553. /**
  33554. * Gets the list of meshes imported to the scene through SceneLoader
  33555. */
  33556. importedMeshesFiles: String[];
  33557. /**
  33558. * Gets or sets a boolean indicating if probes are enabled on this scene
  33559. */
  33560. probesEnabled: boolean;
  33561. /**
  33562. * Gets or sets the current offline provider to use to store scene data
  33563. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33564. */
  33565. offlineProvider: IOfflineProvider;
  33566. /**
  33567. * Gets or sets the action manager associated with the scene
  33568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33569. */
  33570. actionManager: AbstractActionManager;
  33571. private _meshesForIntersections;
  33572. /**
  33573. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33574. */
  33575. proceduralTexturesEnabled: boolean;
  33576. private _engine;
  33577. private _totalVertices;
  33578. /** @hidden */
  33579. _activeIndices: PerfCounter;
  33580. /** @hidden */
  33581. _activeParticles: PerfCounter;
  33582. /** @hidden */
  33583. _activeBones: PerfCounter;
  33584. private _animationRatio;
  33585. /** @hidden */
  33586. _animationTimeLast: number;
  33587. /** @hidden */
  33588. _animationTime: number;
  33589. /**
  33590. * Gets or sets a general scale for animation speed
  33591. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33592. */
  33593. animationTimeScale: number;
  33594. /** @hidden */
  33595. _cachedMaterial: Nullable<Material>;
  33596. /** @hidden */
  33597. _cachedEffect: Nullable<Effect>;
  33598. /** @hidden */
  33599. _cachedVisibility: Nullable<number>;
  33600. private _renderId;
  33601. private _frameId;
  33602. private _executeWhenReadyTimeoutId;
  33603. private _intermediateRendering;
  33604. private _viewUpdateFlag;
  33605. private _projectionUpdateFlag;
  33606. /** @hidden */
  33607. _toBeDisposed: Nullable<IDisposable>[];
  33608. private _activeRequests;
  33609. /** @hidden */
  33610. _pendingData: any[];
  33611. private _isDisposed;
  33612. /**
  33613. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33614. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33615. */
  33616. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33617. private _activeMeshes;
  33618. private _processedMaterials;
  33619. private _renderTargets;
  33620. /** @hidden */
  33621. _activeParticleSystems: SmartArray<IParticleSystem>;
  33622. private _activeSkeletons;
  33623. private _softwareSkinnedMeshes;
  33624. private _renderingManager;
  33625. /** @hidden */
  33626. _activeAnimatables: Animatable[];
  33627. private _transformMatrix;
  33628. private _sceneUbo;
  33629. /** @hidden */
  33630. _viewMatrix: Matrix;
  33631. private _projectionMatrix;
  33632. /** @hidden */
  33633. _forcedViewPosition: Nullable<Vector3>;
  33634. /** @hidden */
  33635. _frustumPlanes: Plane[];
  33636. /**
  33637. * Gets the list of frustum planes (built from the active camera)
  33638. */
  33639. readonly frustumPlanes: Plane[];
  33640. /**
  33641. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33642. * This is useful if there are more lights that the maximum simulteanous authorized
  33643. */
  33644. requireLightSorting: boolean;
  33645. /** @hidden */
  33646. readonly useMaterialMeshMap: boolean;
  33647. /** @hidden */
  33648. readonly useClonedMeshhMap: boolean;
  33649. private _externalData;
  33650. private _uid;
  33651. /**
  33652. * @hidden
  33653. * Backing store of defined scene components.
  33654. */
  33655. _components: ISceneComponent[];
  33656. /**
  33657. * @hidden
  33658. * Backing store of defined scene components.
  33659. */
  33660. _serializableComponents: ISceneSerializableComponent[];
  33661. /**
  33662. * List of components to register on the next registration step.
  33663. */
  33664. private _transientComponents;
  33665. /**
  33666. * Registers the transient components if needed.
  33667. */
  33668. private _registerTransientComponents;
  33669. /**
  33670. * @hidden
  33671. * Add a component to the scene.
  33672. * Note that the ccomponent could be registered on th next frame if this is called after
  33673. * the register component stage.
  33674. * @param component Defines the component to add to the scene
  33675. */
  33676. _addComponent(component: ISceneComponent): void;
  33677. /**
  33678. * @hidden
  33679. * Gets a component from the scene.
  33680. * @param name defines the name of the component to retrieve
  33681. * @returns the component or null if not present
  33682. */
  33683. _getComponent(name: string): Nullable<ISceneComponent>;
  33684. /**
  33685. * @hidden
  33686. * Defines the actions happening before camera updates.
  33687. */
  33688. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33689. /**
  33690. * @hidden
  33691. * Defines the actions happening before clear the canvas.
  33692. */
  33693. _beforeClearStage: Stage<SimpleStageAction>;
  33694. /**
  33695. * @hidden
  33696. * Defines the actions when collecting render targets for the frame.
  33697. */
  33698. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33699. /**
  33700. * @hidden
  33701. * Defines the actions happening for one camera in the frame.
  33702. */
  33703. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33704. /**
  33705. * @hidden
  33706. * Defines the actions happening during the per mesh ready checks.
  33707. */
  33708. _isReadyForMeshStage: Stage<MeshStageAction>;
  33709. /**
  33710. * @hidden
  33711. * Defines the actions happening before evaluate active mesh checks.
  33712. */
  33713. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33714. /**
  33715. * @hidden
  33716. * Defines the actions happening during the evaluate sub mesh checks.
  33717. */
  33718. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33719. /**
  33720. * @hidden
  33721. * Defines the actions happening during the active mesh stage.
  33722. */
  33723. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33724. /**
  33725. * @hidden
  33726. * Defines the actions happening during the per camera render target step.
  33727. */
  33728. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33729. /**
  33730. * @hidden
  33731. * Defines the actions happening just before the active camera is drawing.
  33732. */
  33733. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33734. /**
  33735. * @hidden
  33736. * Defines the actions happening just before a render target is drawing.
  33737. */
  33738. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33739. /**
  33740. * @hidden
  33741. * Defines the actions happening just before a rendering group is drawing.
  33742. */
  33743. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33744. /**
  33745. * @hidden
  33746. * Defines the actions happening just before a mesh is drawing.
  33747. */
  33748. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33749. /**
  33750. * @hidden
  33751. * Defines the actions happening just after a mesh has been drawn.
  33752. */
  33753. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33754. /**
  33755. * @hidden
  33756. * Defines the actions happening just after a rendering group has been drawn.
  33757. */
  33758. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33759. /**
  33760. * @hidden
  33761. * Defines the actions happening just after the active camera has been drawn.
  33762. */
  33763. _afterCameraDrawStage: Stage<CameraStageAction>;
  33764. /**
  33765. * @hidden
  33766. * Defines the actions happening just after a render target has been drawn.
  33767. */
  33768. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33769. /**
  33770. * @hidden
  33771. * Defines the actions happening just after rendering all cameras and computing intersections.
  33772. */
  33773. _afterRenderStage: Stage<SimpleStageAction>;
  33774. /**
  33775. * @hidden
  33776. * Defines the actions happening when a pointer move event happens.
  33777. */
  33778. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33779. /**
  33780. * @hidden
  33781. * Defines the actions happening when a pointer down event happens.
  33782. */
  33783. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33784. /**
  33785. * @hidden
  33786. * Defines the actions happening when a pointer up event happens.
  33787. */
  33788. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33789. /**
  33790. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33791. */
  33792. private geometriesByUniqueId;
  33793. /**
  33794. * Creates a new Scene
  33795. * @param engine defines the engine to use to render this scene
  33796. * @param options defines the scene options
  33797. */
  33798. constructor(engine: Engine, options?: SceneOptions);
  33799. /**
  33800. * Gets a string idenfifying the name of the class
  33801. * @returns "Scene" string
  33802. */
  33803. getClassName(): string;
  33804. private _defaultMeshCandidates;
  33805. /**
  33806. * @hidden
  33807. */
  33808. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33809. private _defaultSubMeshCandidates;
  33810. /**
  33811. * @hidden
  33812. */
  33813. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33814. /**
  33815. * Sets the default candidate providers for the scene.
  33816. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33817. * and getCollidingSubMeshCandidates to their default function
  33818. */
  33819. setDefaultCandidateProviders(): void;
  33820. /**
  33821. * Gets the mesh that is currently under the pointer
  33822. */
  33823. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33824. /**
  33825. * Gets or sets the current on-screen X position of the pointer
  33826. */
  33827. pointerX: number;
  33828. /**
  33829. * Gets or sets the current on-screen Y position of the pointer
  33830. */
  33831. pointerY: number;
  33832. /**
  33833. * Gets the cached material (ie. the latest rendered one)
  33834. * @returns the cached material
  33835. */
  33836. getCachedMaterial(): Nullable<Material>;
  33837. /**
  33838. * Gets the cached effect (ie. the latest rendered one)
  33839. * @returns the cached effect
  33840. */
  33841. getCachedEffect(): Nullable<Effect>;
  33842. /**
  33843. * Gets the cached visibility state (ie. the latest rendered one)
  33844. * @returns the cached visibility state
  33845. */
  33846. getCachedVisibility(): Nullable<number>;
  33847. /**
  33848. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33849. * @param material defines the current material
  33850. * @param effect defines the current effect
  33851. * @param visibility defines the current visibility state
  33852. * @returns true if one parameter is not cached
  33853. */
  33854. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33855. /**
  33856. * Gets the engine associated with the scene
  33857. * @returns an Engine
  33858. */
  33859. getEngine(): Engine;
  33860. /**
  33861. * Gets the total number of vertices rendered per frame
  33862. * @returns the total number of vertices rendered per frame
  33863. */
  33864. getTotalVertices(): number;
  33865. /**
  33866. * Gets the performance counter for total vertices
  33867. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33868. */
  33869. readonly totalVerticesPerfCounter: PerfCounter;
  33870. /**
  33871. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33872. * @returns the total number of active indices rendered per frame
  33873. */
  33874. getActiveIndices(): number;
  33875. /**
  33876. * Gets the performance counter for active indices
  33877. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33878. */
  33879. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33880. /**
  33881. * Gets the total number of active particles rendered per frame
  33882. * @returns the total number of active particles rendered per frame
  33883. */
  33884. getActiveParticles(): number;
  33885. /**
  33886. * Gets the performance counter for active particles
  33887. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33888. */
  33889. readonly activeParticlesPerfCounter: PerfCounter;
  33890. /**
  33891. * Gets the total number of active bones rendered per frame
  33892. * @returns the total number of active bones rendered per frame
  33893. */
  33894. getActiveBones(): number;
  33895. /**
  33896. * Gets the performance counter for active bones
  33897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33898. */
  33899. readonly activeBonesPerfCounter: PerfCounter;
  33900. /**
  33901. * Gets the array of active meshes
  33902. * @returns an array of AbstractMesh
  33903. */
  33904. getActiveMeshes(): SmartArray<AbstractMesh>;
  33905. /**
  33906. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33907. * @returns a number
  33908. */
  33909. getAnimationRatio(): number;
  33910. /**
  33911. * Gets an unique Id for the current render phase
  33912. * @returns a number
  33913. */
  33914. getRenderId(): number;
  33915. /**
  33916. * Gets an unique Id for the current frame
  33917. * @returns a number
  33918. */
  33919. getFrameId(): number;
  33920. /** Call this function if you want to manually increment the render Id*/
  33921. incrementRenderId(): void;
  33922. private _createUbo;
  33923. /**
  33924. * Use this method to simulate a pointer move on a mesh
  33925. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33926. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33927. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33928. * @returns the current scene
  33929. */
  33930. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33931. /**
  33932. * Use this method to simulate a pointer down on a mesh
  33933. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33934. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33935. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33936. * @returns the current scene
  33937. */
  33938. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33939. /**
  33940. * Use this method to simulate a pointer up on a mesh
  33941. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33942. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33943. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33944. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33945. * @returns the current scene
  33946. */
  33947. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33948. /**
  33949. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33950. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33951. * @returns true if the pointer was captured
  33952. */
  33953. isPointerCaptured(pointerId?: number): boolean;
  33954. /**
  33955. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33956. * @param attachUp defines if you want to attach events to pointerup
  33957. * @param attachDown defines if you want to attach events to pointerdown
  33958. * @param attachMove defines if you want to attach events to pointermove
  33959. */
  33960. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33961. /** Detaches all event handlers*/
  33962. detachControl(): void;
  33963. /**
  33964. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33965. * Delay loaded resources are not taking in account
  33966. * @return true if all required resources are ready
  33967. */
  33968. isReady(): boolean;
  33969. /** Resets all cached information relative to material (including effect and visibility) */
  33970. resetCachedMaterial(): void;
  33971. /**
  33972. * Registers a function to be called before every frame render
  33973. * @param func defines the function to register
  33974. */
  33975. registerBeforeRender(func: () => void): void;
  33976. /**
  33977. * Unregisters a function called before every frame render
  33978. * @param func defines the function to unregister
  33979. */
  33980. unregisterBeforeRender(func: () => void): void;
  33981. /**
  33982. * Registers a function to be called after every frame render
  33983. * @param func defines the function to register
  33984. */
  33985. registerAfterRender(func: () => void): void;
  33986. /**
  33987. * Unregisters a function called after every frame render
  33988. * @param func defines the function to unregister
  33989. */
  33990. unregisterAfterRender(func: () => void): void;
  33991. private _executeOnceBeforeRender;
  33992. /**
  33993. * The provided function will run before render once and will be disposed afterwards.
  33994. * A timeout delay can be provided so that the function will be executed in N ms.
  33995. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33996. * @param func The function to be executed.
  33997. * @param timeout optional delay in ms
  33998. */
  33999. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34000. /** @hidden */
  34001. _addPendingData(data: any): void;
  34002. /** @hidden */
  34003. _removePendingData(data: any): void;
  34004. /**
  34005. * Returns the number of items waiting to be loaded
  34006. * @returns the number of items waiting to be loaded
  34007. */
  34008. getWaitingItemsCount(): number;
  34009. /**
  34010. * Returns a boolean indicating if the scene is still loading data
  34011. */
  34012. readonly isLoading: boolean;
  34013. /**
  34014. * Registers a function to be executed when the scene is ready
  34015. * @param {Function} func - the function to be executed
  34016. */
  34017. executeWhenReady(func: () => void): void;
  34018. /**
  34019. * Returns a promise that resolves when the scene is ready
  34020. * @returns A promise that resolves when the scene is ready
  34021. */
  34022. whenReadyAsync(): Promise<void>;
  34023. /** @hidden */
  34024. _checkIsReady(): void;
  34025. /**
  34026. * Gets all animatable attached to the scene
  34027. */
  34028. readonly animatables: Animatable[];
  34029. /**
  34030. * Resets the last animation time frame.
  34031. * Useful to override when animations start running when loading a scene for the first time.
  34032. */
  34033. resetLastAnimationTimeFrame(): void;
  34034. /**
  34035. * Gets the current view matrix
  34036. * @returns a Matrix
  34037. */
  34038. getViewMatrix(): Matrix;
  34039. /**
  34040. * Gets the current projection matrix
  34041. * @returns a Matrix
  34042. */
  34043. getProjectionMatrix(): Matrix;
  34044. /**
  34045. * Gets the current transform matrix
  34046. * @returns a Matrix made of View * Projection
  34047. */
  34048. getTransformMatrix(): Matrix;
  34049. /**
  34050. * Sets the current transform matrix
  34051. * @param viewL defines the View matrix to use
  34052. * @param projectionL defines the Projection matrix to use
  34053. * @param viewR defines the right View matrix to use (if provided)
  34054. * @param projectionR defines the right Projection matrix to use (if provided)
  34055. */
  34056. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34057. /**
  34058. * Gets the uniform buffer used to store scene data
  34059. * @returns a UniformBuffer
  34060. */
  34061. getSceneUniformBuffer(): UniformBuffer;
  34062. /**
  34063. * Gets an unique (relatively to the current scene) Id
  34064. * @returns an unique number for the scene
  34065. */
  34066. getUniqueId(): number;
  34067. /**
  34068. * Add a mesh to the list of scene's meshes
  34069. * @param newMesh defines the mesh to add
  34070. * @param recursive if all child meshes should also be added to the scene
  34071. */
  34072. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34073. /**
  34074. * Remove a mesh for the list of scene's meshes
  34075. * @param toRemove defines the mesh to remove
  34076. * @param recursive if all child meshes should also be removed from the scene
  34077. * @returns the index where the mesh was in the mesh list
  34078. */
  34079. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34080. /**
  34081. * Add a transform node to the list of scene's transform nodes
  34082. * @param newTransformNode defines the transform node to add
  34083. */
  34084. addTransformNode(newTransformNode: TransformNode): void;
  34085. /**
  34086. * Remove a transform node for the list of scene's transform nodes
  34087. * @param toRemove defines the transform node to remove
  34088. * @returns the index where the transform node was in the transform node list
  34089. */
  34090. removeTransformNode(toRemove: TransformNode): number;
  34091. /**
  34092. * Remove a skeleton for the list of scene's skeletons
  34093. * @param toRemove defines the skeleton to remove
  34094. * @returns the index where the skeleton was in the skeleton list
  34095. */
  34096. removeSkeleton(toRemove: Skeleton): number;
  34097. /**
  34098. * Remove a morph target for the list of scene's morph targets
  34099. * @param toRemove defines the morph target to remove
  34100. * @returns the index where the morph target was in the morph target list
  34101. */
  34102. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34103. /**
  34104. * Remove a light for the list of scene's lights
  34105. * @param toRemove defines the light to remove
  34106. * @returns the index where the light was in the light list
  34107. */
  34108. removeLight(toRemove: Light): number;
  34109. /**
  34110. * Remove a camera for the list of scene's cameras
  34111. * @param toRemove defines the camera to remove
  34112. * @returns the index where the camera was in the camera list
  34113. */
  34114. removeCamera(toRemove: Camera): number;
  34115. /**
  34116. * Remove a particle system for the list of scene's particle systems
  34117. * @param toRemove defines the particle system to remove
  34118. * @returns the index where the particle system was in the particle system list
  34119. */
  34120. removeParticleSystem(toRemove: IParticleSystem): number;
  34121. /**
  34122. * Remove a animation for the list of scene's animations
  34123. * @param toRemove defines the animation to remove
  34124. * @returns the index where the animation was in the animation list
  34125. */
  34126. removeAnimation(toRemove: Animation): number;
  34127. /**
  34128. * Will stop the animation of the given target
  34129. * @param target - the target
  34130. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34131. * @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)
  34132. */
  34133. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34134. /**
  34135. * Removes the given animation group from this scene.
  34136. * @param toRemove The animation group to remove
  34137. * @returns The index of the removed animation group
  34138. */
  34139. removeAnimationGroup(toRemove: AnimationGroup): number;
  34140. /**
  34141. * Removes the given multi-material from this scene.
  34142. * @param toRemove The multi-material to remove
  34143. * @returns The index of the removed multi-material
  34144. */
  34145. removeMultiMaterial(toRemove: MultiMaterial): number;
  34146. /**
  34147. * Removes the given material from this scene.
  34148. * @param toRemove The material to remove
  34149. * @returns The index of the removed material
  34150. */
  34151. removeMaterial(toRemove: Material): number;
  34152. /**
  34153. * Removes the given action manager from this scene.
  34154. * @param toRemove The action manager to remove
  34155. * @returns The index of the removed action manager
  34156. */
  34157. removeActionManager(toRemove: AbstractActionManager): number;
  34158. /**
  34159. * Removes the given texture from this scene.
  34160. * @param toRemove The texture to remove
  34161. * @returns The index of the removed texture
  34162. */
  34163. removeTexture(toRemove: BaseTexture): number;
  34164. /**
  34165. * Adds the given light to this scene
  34166. * @param newLight The light to add
  34167. */
  34168. addLight(newLight: Light): void;
  34169. /**
  34170. * Sorts the list list based on light priorities
  34171. */
  34172. sortLightsByPriority(): void;
  34173. /**
  34174. * Adds the given camera to this scene
  34175. * @param newCamera The camera to add
  34176. */
  34177. addCamera(newCamera: Camera): void;
  34178. /**
  34179. * Adds the given skeleton to this scene
  34180. * @param newSkeleton The skeleton to add
  34181. */
  34182. addSkeleton(newSkeleton: Skeleton): void;
  34183. /**
  34184. * Adds the given particle system to this scene
  34185. * @param newParticleSystem The particle system to add
  34186. */
  34187. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34188. /**
  34189. * Adds the given animation to this scene
  34190. * @param newAnimation The animation to add
  34191. */
  34192. addAnimation(newAnimation: Animation): void;
  34193. /**
  34194. * Adds the given animation group to this scene.
  34195. * @param newAnimationGroup The animation group to add
  34196. */
  34197. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34198. /**
  34199. * Adds the given multi-material to this scene
  34200. * @param newMultiMaterial The multi-material to add
  34201. */
  34202. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34203. /**
  34204. * Adds the given material to this scene
  34205. * @param newMaterial The material to add
  34206. */
  34207. addMaterial(newMaterial: Material): void;
  34208. /**
  34209. * Adds the given morph target to this scene
  34210. * @param newMorphTargetManager The morph target to add
  34211. */
  34212. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34213. /**
  34214. * Adds the given geometry to this scene
  34215. * @param newGeometry The geometry to add
  34216. */
  34217. addGeometry(newGeometry: Geometry): void;
  34218. /**
  34219. * Adds the given action manager to this scene
  34220. * @param newActionManager The action manager to add
  34221. */
  34222. addActionManager(newActionManager: AbstractActionManager): void;
  34223. /**
  34224. * Adds the given texture to this scene.
  34225. * @param newTexture The texture to add
  34226. */
  34227. addTexture(newTexture: BaseTexture): void;
  34228. /**
  34229. * Switch active camera
  34230. * @param newCamera defines the new active camera
  34231. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34232. */
  34233. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34234. /**
  34235. * sets the active camera of the scene using its ID
  34236. * @param id defines the camera's ID
  34237. * @return the new active camera or null if none found.
  34238. */
  34239. setActiveCameraByID(id: string): Nullable<Camera>;
  34240. /**
  34241. * sets the active camera of the scene using its name
  34242. * @param name defines the camera's name
  34243. * @returns the new active camera or null if none found.
  34244. */
  34245. setActiveCameraByName(name: string): Nullable<Camera>;
  34246. /**
  34247. * get an animation group using its name
  34248. * @param name defines the material's name
  34249. * @return the animation group or null if none found.
  34250. */
  34251. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34252. /**
  34253. * Get a material using its unique id
  34254. * @param uniqueId defines the material's unique id
  34255. * @return the material or null if none found.
  34256. */
  34257. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34258. /**
  34259. * get a material using its id
  34260. * @param id defines the material's ID
  34261. * @return the material or null if none found.
  34262. */
  34263. getMaterialByID(id: string): Nullable<Material>;
  34264. /**
  34265. * Gets a the last added material using a given id
  34266. * @param id defines the material's ID
  34267. * @return the last material with the given id or null if none found.
  34268. */
  34269. getLastMaterialByID(id: string): Nullable<Material>;
  34270. /**
  34271. * Gets a material using its name
  34272. * @param name defines the material's name
  34273. * @return the material or null if none found.
  34274. */
  34275. getMaterialByName(name: string): Nullable<Material>;
  34276. /**
  34277. * Get a texture using its unique id
  34278. * @param uniqueId defines the texture's unique id
  34279. * @return the texture or null if none found.
  34280. */
  34281. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  34282. /**
  34283. * Gets a camera using its id
  34284. * @param id defines the id to look for
  34285. * @returns the camera or null if not found
  34286. */
  34287. getCameraByID(id: string): Nullable<Camera>;
  34288. /**
  34289. * Gets a camera using its unique id
  34290. * @param uniqueId defines the unique id to look for
  34291. * @returns the camera or null if not found
  34292. */
  34293. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34294. /**
  34295. * Gets a camera using its name
  34296. * @param name defines the camera's name
  34297. * @return the camera or null if none found.
  34298. */
  34299. getCameraByName(name: string): Nullable<Camera>;
  34300. /**
  34301. * Gets a bone using its id
  34302. * @param id defines the bone's id
  34303. * @return the bone or null if not found
  34304. */
  34305. getBoneByID(id: string): Nullable<Bone>;
  34306. /**
  34307. * Gets a bone using its id
  34308. * @param name defines the bone's name
  34309. * @return the bone or null if not found
  34310. */
  34311. getBoneByName(name: string): Nullable<Bone>;
  34312. /**
  34313. * Gets a light node using its name
  34314. * @param name defines the the light's name
  34315. * @return the light or null if none found.
  34316. */
  34317. getLightByName(name: string): Nullable<Light>;
  34318. /**
  34319. * Gets a light node using its id
  34320. * @param id defines the light's id
  34321. * @return the light or null if none found.
  34322. */
  34323. getLightByID(id: string): Nullable<Light>;
  34324. /**
  34325. * Gets a light node using its scene-generated unique ID
  34326. * @param uniqueId defines the light's unique id
  34327. * @return the light or null if none found.
  34328. */
  34329. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34330. /**
  34331. * Gets a particle system by id
  34332. * @param id defines the particle system id
  34333. * @return the corresponding system or null if none found
  34334. */
  34335. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34336. /**
  34337. * Gets a geometry using its ID
  34338. * @param id defines the geometry's id
  34339. * @return the geometry or null if none found.
  34340. */
  34341. getGeometryByID(id: string): Nullable<Geometry>;
  34342. private _getGeometryByUniqueID;
  34343. /**
  34344. * Add a new geometry to this scene
  34345. * @param geometry defines the geometry to be added to the scene.
  34346. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34347. * @return a boolean defining if the geometry was added or not
  34348. */
  34349. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34350. /**
  34351. * Removes an existing geometry
  34352. * @param geometry defines the geometry to be removed from the scene
  34353. * @return a boolean defining if the geometry was removed or not
  34354. */
  34355. removeGeometry(geometry: Geometry): boolean;
  34356. /**
  34357. * Gets the list of geometries attached to the scene
  34358. * @returns an array of Geometry
  34359. */
  34360. getGeometries(): Geometry[];
  34361. /**
  34362. * Gets the first added mesh found of a given ID
  34363. * @param id defines the id to search for
  34364. * @return the mesh found or null if not found at all
  34365. */
  34366. getMeshByID(id: string): Nullable<AbstractMesh>;
  34367. /**
  34368. * Gets a list of meshes using their id
  34369. * @param id defines the id to search for
  34370. * @returns a list of meshes
  34371. */
  34372. getMeshesByID(id: string): Array<AbstractMesh>;
  34373. /**
  34374. * Gets the first added transform node found of a given ID
  34375. * @param id defines the id to search for
  34376. * @return the found transform node or null if not found at all.
  34377. */
  34378. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34379. /**
  34380. * Gets a transform node with its auto-generated unique id
  34381. * @param uniqueId efines the unique id to search for
  34382. * @return the found transform node or null if not found at all.
  34383. */
  34384. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34385. /**
  34386. * Gets a list of transform nodes using their id
  34387. * @param id defines the id to search for
  34388. * @returns a list of transform nodes
  34389. */
  34390. getTransformNodesByID(id: string): Array<TransformNode>;
  34391. /**
  34392. * Gets a mesh with its auto-generated unique id
  34393. * @param uniqueId defines the unique id to search for
  34394. * @return the found mesh or null if not found at all.
  34395. */
  34396. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34397. /**
  34398. * Gets a the last added mesh using a given id
  34399. * @param id defines the id to search for
  34400. * @return the found mesh or null if not found at all.
  34401. */
  34402. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34403. /**
  34404. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34405. * @param id defines the id to search for
  34406. * @return the found node or null if not found at all
  34407. */
  34408. getLastEntryByID(id: string): Nullable<Node>;
  34409. /**
  34410. * Gets a node (Mesh, Camera, Light) using a given id
  34411. * @param id defines the id to search for
  34412. * @return the found node or null if not found at all
  34413. */
  34414. getNodeByID(id: string): Nullable<Node>;
  34415. /**
  34416. * Gets a node (Mesh, Camera, Light) using a given name
  34417. * @param name defines the name to search for
  34418. * @return the found node or null if not found at all.
  34419. */
  34420. getNodeByName(name: string): Nullable<Node>;
  34421. /**
  34422. * Gets a mesh using a given name
  34423. * @param name defines the name to search for
  34424. * @return the found mesh or null if not found at all.
  34425. */
  34426. getMeshByName(name: string): Nullable<AbstractMesh>;
  34427. /**
  34428. * Gets a transform node using a given name
  34429. * @param name defines the name to search for
  34430. * @return the found transform node or null if not found at all.
  34431. */
  34432. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34433. /**
  34434. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34435. * @param id defines the id to search for
  34436. * @return the found skeleton or null if not found at all.
  34437. */
  34438. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34439. /**
  34440. * Gets a skeleton using a given auto generated unique id
  34441. * @param uniqueId defines the unique id to search for
  34442. * @return the found skeleton or null if not found at all.
  34443. */
  34444. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34445. /**
  34446. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34447. * @param id defines the id to search for
  34448. * @return the found skeleton or null if not found at all.
  34449. */
  34450. getSkeletonById(id: string): Nullable<Skeleton>;
  34451. /**
  34452. * Gets a skeleton using a given name
  34453. * @param name defines the name to search for
  34454. * @return the found skeleton or null if not found at all.
  34455. */
  34456. getSkeletonByName(name: string): Nullable<Skeleton>;
  34457. /**
  34458. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34459. * @param id defines the id to search for
  34460. * @return the found morph target manager or null if not found at all.
  34461. */
  34462. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34463. /**
  34464. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34465. * @param id defines the id to search for
  34466. * @return the found morph target or null if not found at all.
  34467. */
  34468. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34469. /**
  34470. * Gets a boolean indicating if the given mesh is active
  34471. * @param mesh defines the mesh to look for
  34472. * @returns true if the mesh is in the active list
  34473. */
  34474. isActiveMesh(mesh: AbstractMesh): boolean;
  34475. /**
  34476. * Return a unique id as a string which can serve as an identifier for the scene
  34477. */
  34478. readonly uid: string;
  34479. /**
  34480. * Add an externaly attached data from its key.
  34481. * This method call will fail and return false, if such key already exists.
  34482. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34483. * @param key the unique key that identifies the data
  34484. * @param data the data object to associate to the key for this Engine instance
  34485. * @return true if no such key were already present and the data was added successfully, false otherwise
  34486. */
  34487. addExternalData<T>(key: string, data: T): boolean;
  34488. /**
  34489. * Get an externaly attached data from its key
  34490. * @param key the unique key that identifies the data
  34491. * @return the associated data, if present (can be null), or undefined if not present
  34492. */
  34493. getExternalData<T>(key: string): Nullable<T>;
  34494. /**
  34495. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34496. * @param key the unique key that identifies the data
  34497. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34498. * @return the associated data, can be null if the factory returned null.
  34499. */
  34500. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34501. /**
  34502. * Remove an externaly attached data from the Engine instance
  34503. * @param key the unique key that identifies the data
  34504. * @return true if the data was successfully removed, false if it doesn't exist
  34505. */
  34506. removeExternalData(key: string): boolean;
  34507. private _evaluateSubMesh;
  34508. /**
  34509. * Clear the processed materials smart array preventing retention point in material dispose.
  34510. */
  34511. freeProcessedMaterials(): void;
  34512. private _preventFreeActiveMeshesAndRenderingGroups;
  34513. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34514. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34515. * when disposing several meshes in a row or a hierarchy of meshes.
  34516. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34517. */
  34518. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34519. /**
  34520. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34521. */
  34522. freeActiveMeshes(): void;
  34523. /**
  34524. * Clear the info related to rendering groups preventing retention points during dispose.
  34525. */
  34526. freeRenderingGroups(): void;
  34527. /** @hidden */
  34528. _isInIntermediateRendering(): boolean;
  34529. /**
  34530. * Lambda returning the list of potentially active meshes.
  34531. */
  34532. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34533. /**
  34534. * Lambda returning the list of potentially active sub meshes.
  34535. */
  34536. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34537. /**
  34538. * Lambda returning the list of potentially intersecting sub meshes.
  34539. */
  34540. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34541. /**
  34542. * Lambda returning the list of potentially colliding sub meshes.
  34543. */
  34544. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34545. private _activeMeshesFrozen;
  34546. /**
  34547. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34548. * @returns the current scene
  34549. */
  34550. freezeActiveMeshes(): Scene;
  34551. /**
  34552. * Use this function to restart evaluating active meshes on every frame
  34553. * @returns the current scene
  34554. */
  34555. unfreezeActiveMeshes(): Scene;
  34556. private _evaluateActiveMeshes;
  34557. private _activeMesh;
  34558. /**
  34559. * Update the transform matrix to update from the current active camera
  34560. * @param force defines a boolean used to force the update even if cache is up to date
  34561. */
  34562. updateTransformMatrix(force?: boolean): void;
  34563. private _bindFrameBuffer;
  34564. /** @hidden */
  34565. _allowPostProcessClearColor: boolean;
  34566. /** @hidden */
  34567. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34568. private _processSubCameras;
  34569. private _checkIntersections;
  34570. /** @hidden */
  34571. _advancePhysicsEngineStep(step: number): void;
  34572. /**
  34573. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34574. */
  34575. getDeterministicFrameTime: () => number;
  34576. /** @hidden */
  34577. _animate(): void;
  34578. /** Execute all animations (for a frame) */
  34579. animate(): void;
  34580. /**
  34581. * Render the scene
  34582. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34583. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34584. */
  34585. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34586. /**
  34587. * Freeze all materials
  34588. * A frozen material will not be updatable but should be faster to render
  34589. */
  34590. freezeMaterials(): void;
  34591. /**
  34592. * Unfreeze all materials
  34593. * A frozen material will not be updatable but should be faster to render
  34594. */
  34595. unfreezeMaterials(): void;
  34596. /**
  34597. * Releases all held ressources
  34598. */
  34599. dispose(): void;
  34600. /**
  34601. * Gets if the scene is already disposed
  34602. */
  34603. readonly isDisposed: boolean;
  34604. /**
  34605. * Call this function to reduce memory footprint of the scene.
  34606. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34607. */
  34608. clearCachedVertexData(): void;
  34609. /**
  34610. * This function will remove the local cached buffer data from texture.
  34611. * It will save memory but will prevent the texture from being rebuilt
  34612. */
  34613. cleanCachedTextureBuffer(): void;
  34614. /**
  34615. * Get the world extend vectors with an optional filter
  34616. *
  34617. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34618. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34619. */
  34620. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34621. min: Vector3;
  34622. max: Vector3;
  34623. };
  34624. /**
  34625. * Creates a ray that can be used to pick in the scene
  34626. * @param x defines the x coordinate of the origin (on-screen)
  34627. * @param y defines the y coordinate of the origin (on-screen)
  34628. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34629. * @param camera defines the camera to use for the picking
  34630. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34631. * @returns a Ray
  34632. */
  34633. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34634. /**
  34635. * Creates a ray that can be used to pick in the scene
  34636. * @param x defines the x coordinate of the origin (on-screen)
  34637. * @param y defines the y coordinate of the origin (on-screen)
  34638. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34639. * @param result defines the ray where to store the picking ray
  34640. * @param camera defines the camera to use for the picking
  34641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34642. * @returns the current scene
  34643. */
  34644. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34645. /**
  34646. * Creates a ray that can be used to pick in the scene
  34647. * @param x defines the x coordinate of the origin (on-screen)
  34648. * @param y defines the y coordinate of the origin (on-screen)
  34649. * @param camera defines the camera to use for the picking
  34650. * @returns a Ray
  34651. */
  34652. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34653. /**
  34654. * Creates a ray that can be used to pick in the scene
  34655. * @param x defines the x coordinate of the origin (on-screen)
  34656. * @param y defines the y coordinate of the origin (on-screen)
  34657. * @param result defines the ray where to store the picking ray
  34658. * @param camera defines the camera to use for the picking
  34659. * @returns the current scene
  34660. */
  34661. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34662. /** Launch a ray to try to pick a mesh in the scene
  34663. * @param x position on screen
  34664. * @param y position on screen
  34665. * @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
  34666. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34667. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34668. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34669. * @returns a PickingInfo
  34670. */
  34671. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34672. /** Use the given ray to pick a mesh in the scene
  34673. * @param ray The ray to use to pick meshes
  34674. * @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
  34675. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34677. * @returns a PickingInfo
  34678. */
  34679. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34680. /**
  34681. * Launch a ray to try to pick a mesh in the scene
  34682. * @param x X position on screen
  34683. * @param y Y position on screen
  34684. * @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
  34685. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34687. * @returns an array of PickingInfo
  34688. */
  34689. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34690. /**
  34691. * Launch a ray to try to pick a mesh in the scene
  34692. * @param ray Ray to use
  34693. * @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
  34694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34695. * @returns an array of PickingInfo
  34696. */
  34697. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34698. /**
  34699. * Force the value of meshUnderPointer
  34700. * @param mesh defines the mesh to use
  34701. */
  34702. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34703. /**
  34704. * Gets the mesh under the pointer
  34705. * @returns a Mesh or null if no mesh is under the pointer
  34706. */
  34707. getPointerOverMesh(): Nullable<AbstractMesh>;
  34708. /** @hidden */
  34709. _rebuildGeometries(): void;
  34710. /** @hidden */
  34711. _rebuildTextures(): void;
  34712. private _getByTags;
  34713. /**
  34714. * Get a list of meshes by tags
  34715. * @param tagsQuery defines the tags query to use
  34716. * @param forEach defines a predicate used to filter results
  34717. * @returns an array of Mesh
  34718. */
  34719. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34720. /**
  34721. * Get a list of cameras by tags
  34722. * @param tagsQuery defines the tags query to use
  34723. * @param forEach defines a predicate used to filter results
  34724. * @returns an array of Camera
  34725. */
  34726. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34727. /**
  34728. * Get a list of lights by tags
  34729. * @param tagsQuery defines the tags query to use
  34730. * @param forEach defines a predicate used to filter results
  34731. * @returns an array of Light
  34732. */
  34733. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34734. /**
  34735. * Get a list of materials by tags
  34736. * @param tagsQuery defines the tags query to use
  34737. * @param forEach defines a predicate used to filter results
  34738. * @returns an array of Material
  34739. */
  34740. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34741. /**
  34742. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34743. * This allowed control for front to back rendering or reversly depending of the special needs.
  34744. *
  34745. * @param renderingGroupId The rendering group id corresponding to its index
  34746. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34747. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34748. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34749. */
  34750. 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;
  34751. /**
  34752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34753. *
  34754. * @param renderingGroupId The rendering group id corresponding to its index
  34755. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34756. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34757. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34758. */
  34759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34760. /**
  34761. * Gets the current auto clear configuration for one rendering group of the rendering
  34762. * manager.
  34763. * @param index the rendering group index to get the information for
  34764. * @returns The auto clear setup for the requested rendering group
  34765. */
  34766. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34767. private _blockMaterialDirtyMechanism;
  34768. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34769. blockMaterialDirtyMechanism: boolean;
  34770. /**
  34771. * Will flag all materials as dirty to trigger new shader compilation
  34772. * @param flag defines the flag used to specify which material part must be marked as dirty
  34773. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34774. */
  34775. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34776. /** @hidden */
  34777. _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;
  34778. /** @hidden */
  34779. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34780. }
  34781. }
  34782. declare module BABYLON {
  34783. /**
  34784. * Set of assets to keep when moving a scene into an asset container.
  34785. */
  34786. export class KeepAssets extends AbstractScene {
  34787. }
  34788. /**
  34789. * Container with a set of assets that can be added or removed from a scene.
  34790. */
  34791. export class AssetContainer extends AbstractScene {
  34792. /**
  34793. * The scene the AssetContainer belongs to.
  34794. */
  34795. scene: Scene;
  34796. /**
  34797. * Instantiates an AssetContainer.
  34798. * @param scene The scene the AssetContainer belongs to.
  34799. */
  34800. constructor(scene: Scene);
  34801. /**
  34802. * Adds all the assets from the container to the scene.
  34803. */
  34804. addAllToScene(): void;
  34805. /**
  34806. * Removes all the assets in the container from the scene
  34807. */
  34808. removeAllFromScene(): void;
  34809. /**
  34810. * Disposes all the assets in the container
  34811. */
  34812. dispose(): void;
  34813. private _moveAssets;
  34814. /**
  34815. * Removes all the assets contained in the scene and adds them to the container.
  34816. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34817. */
  34818. moveAllFromScene(keepAssets?: KeepAssets): void;
  34819. /**
  34820. * 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.
  34821. * @returns the root mesh
  34822. */
  34823. createRootMesh(): Mesh;
  34824. }
  34825. }
  34826. declare module BABYLON {
  34827. /**
  34828. * Defines how the parser contract is defined.
  34829. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34830. */
  34831. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34832. /**
  34833. * Defines how the individual parser contract is defined.
  34834. * These parser can parse an individual asset
  34835. */
  34836. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34837. /**
  34838. * Base class of the scene acting as a container for the different elements composing a scene.
  34839. * This class is dynamically extended by the different components of the scene increasing
  34840. * flexibility and reducing coupling
  34841. */
  34842. export abstract class AbstractScene {
  34843. /**
  34844. * Stores the list of available parsers in the application.
  34845. */
  34846. private static _BabylonFileParsers;
  34847. /**
  34848. * Stores the list of available individual parsers in the application.
  34849. */
  34850. private static _IndividualBabylonFileParsers;
  34851. /**
  34852. * Adds a parser in the list of available ones
  34853. * @param name Defines the name of the parser
  34854. * @param parser Defines the parser to add
  34855. */
  34856. static AddParser(name: string, parser: BabylonFileParser): void;
  34857. /**
  34858. * Gets a general parser from the list of avaialble ones
  34859. * @param name Defines the name of the parser
  34860. * @returns the requested parser or null
  34861. */
  34862. static GetParser(name: string): Nullable<BabylonFileParser>;
  34863. /**
  34864. * Adds n individual parser in the list of available ones
  34865. * @param name Defines the name of the parser
  34866. * @param parser Defines the parser to add
  34867. */
  34868. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34869. /**
  34870. * Gets an individual parser from the list of avaialble ones
  34871. * @param name Defines the name of the parser
  34872. * @returns the requested parser or null
  34873. */
  34874. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34875. /**
  34876. * Parser json data and populate both a scene and its associated container object
  34877. * @param jsonData Defines the data to parse
  34878. * @param scene Defines the scene to parse the data for
  34879. * @param container Defines the container attached to the parsing sequence
  34880. * @param rootUrl Defines the root url of the data
  34881. */
  34882. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34883. /**
  34884. * Gets the list of root nodes (ie. nodes with no parent)
  34885. */
  34886. rootNodes: Node[];
  34887. /** All of the cameras added to this scene
  34888. * @see http://doc.babylonjs.com/babylon101/cameras
  34889. */
  34890. cameras: Camera[];
  34891. /**
  34892. * All of the lights added to this scene
  34893. * @see http://doc.babylonjs.com/babylon101/lights
  34894. */
  34895. lights: Light[];
  34896. /**
  34897. * All of the (abstract) meshes added to this scene
  34898. */
  34899. meshes: AbstractMesh[];
  34900. /**
  34901. * The list of skeletons added to the scene
  34902. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34903. */
  34904. skeletons: Skeleton[];
  34905. /**
  34906. * All of the particle systems added to this scene
  34907. * @see http://doc.babylonjs.com/babylon101/particles
  34908. */
  34909. particleSystems: IParticleSystem[];
  34910. /**
  34911. * Gets a list of Animations associated with the scene
  34912. */
  34913. animations: Animation[];
  34914. /**
  34915. * All of the animation groups added to this scene
  34916. * @see http://doc.babylonjs.com/how_to/group
  34917. */
  34918. animationGroups: AnimationGroup[];
  34919. /**
  34920. * All of the multi-materials added to this scene
  34921. * @see http://doc.babylonjs.com/how_to/multi_materials
  34922. */
  34923. multiMaterials: MultiMaterial[];
  34924. /**
  34925. * All of the materials added to this scene
  34926. * In the context of a Scene, it is not supposed to be modified manually.
  34927. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34928. * Note also that the order of the Material wihin the array is not significant and might change.
  34929. * @see http://doc.babylonjs.com/babylon101/materials
  34930. */
  34931. materials: Material[];
  34932. /**
  34933. * The list of morph target managers added to the scene
  34934. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34935. */
  34936. morphTargetManagers: MorphTargetManager[];
  34937. /**
  34938. * The list of geometries used in the scene.
  34939. */
  34940. geometries: Geometry[];
  34941. /**
  34942. * All of the tranform nodes added to this scene
  34943. * In the context of a Scene, it is not supposed to be modified manually.
  34944. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34945. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34946. * @see http://doc.babylonjs.com/how_to/transformnode
  34947. */
  34948. transformNodes: TransformNode[];
  34949. /**
  34950. * ActionManagers available on the scene.
  34951. */
  34952. actionManagers: AbstractActionManager[];
  34953. /**
  34954. * Textures to keep.
  34955. */
  34956. textures: BaseTexture[];
  34957. /**
  34958. * Environment texture for the scene
  34959. */
  34960. environmentTexture: Nullable<BaseTexture>;
  34961. }
  34962. }
  34963. declare module BABYLON {
  34964. /**
  34965. * Interface used to define options for Sound class
  34966. */
  34967. export interface ISoundOptions {
  34968. /**
  34969. * Does the sound autoplay once loaded.
  34970. */
  34971. autoplay?: boolean;
  34972. /**
  34973. * Does the sound loop after it finishes playing once.
  34974. */
  34975. loop?: boolean;
  34976. /**
  34977. * Sound's volume
  34978. */
  34979. volume?: number;
  34980. /**
  34981. * Is it a spatial sound?
  34982. */
  34983. spatialSound?: boolean;
  34984. /**
  34985. * Maximum distance to hear that sound
  34986. */
  34987. maxDistance?: number;
  34988. /**
  34989. * Uses user defined attenuation function
  34990. */
  34991. useCustomAttenuation?: boolean;
  34992. /**
  34993. * Define the roll off factor of spatial sounds.
  34994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34995. */
  34996. rolloffFactor?: number;
  34997. /**
  34998. * Define the reference distance the sound should be heard perfectly.
  34999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35000. */
  35001. refDistance?: number;
  35002. /**
  35003. * Define the distance attenuation model the sound will follow.
  35004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35005. */
  35006. distanceModel?: string;
  35007. /**
  35008. * Defines the playback speed (1 by default)
  35009. */
  35010. playbackRate?: number;
  35011. /**
  35012. * Defines if the sound is from a streaming source
  35013. */
  35014. streaming?: boolean;
  35015. /**
  35016. * Defines an optional length (in seconds) inside the sound file
  35017. */
  35018. length?: number;
  35019. /**
  35020. * Defines an optional offset (in seconds) inside the sound file
  35021. */
  35022. offset?: number;
  35023. /**
  35024. * If true, URLs will not be required to state the audio file codec to use.
  35025. */
  35026. skipCodecCheck?: boolean;
  35027. }
  35028. /**
  35029. * Defines a sound that can be played in the application.
  35030. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35032. */
  35033. export class Sound {
  35034. /**
  35035. * The name of the sound in the scene.
  35036. */
  35037. name: string;
  35038. /**
  35039. * Does the sound autoplay once loaded.
  35040. */
  35041. autoplay: boolean;
  35042. /**
  35043. * Does the sound loop after it finishes playing once.
  35044. */
  35045. loop: boolean;
  35046. /**
  35047. * Does the sound use a custom attenuation curve to simulate the falloff
  35048. * happening when the source gets further away from the camera.
  35049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35050. */
  35051. useCustomAttenuation: boolean;
  35052. /**
  35053. * The sound track id this sound belongs to.
  35054. */
  35055. soundTrackId: number;
  35056. /**
  35057. * Is this sound currently played.
  35058. */
  35059. isPlaying: boolean;
  35060. /**
  35061. * Is this sound currently paused.
  35062. */
  35063. isPaused: boolean;
  35064. /**
  35065. * Does this sound enables spatial sound.
  35066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35067. */
  35068. spatialSound: boolean;
  35069. /**
  35070. * Define the reference distance the sound should be heard perfectly.
  35071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35072. */
  35073. refDistance: number;
  35074. /**
  35075. * Define the roll off factor of spatial sounds.
  35076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35077. */
  35078. rolloffFactor: number;
  35079. /**
  35080. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35082. */
  35083. maxDistance: number;
  35084. /**
  35085. * Define the distance attenuation model the sound will follow.
  35086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35087. */
  35088. distanceModel: string;
  35089. /**
  35090. * @hidden
  35091. * Back Compat
  35092. **/
  35093. onended: () => any;
  35094. /**
  35095. * Observable event when the current playing sound finishes.
  35096. */
  35097. onEndedObservable: Observable<Sound>;
  35098. private _panningModel;
  35099. private _playbackRate;
  35100. private _streaming;
  35101. private _startTime;
  35102. private _startOffset;
  35103. private _position;
  35104. /** @hidden */
  35105. _positionInEmitterSpace: boolean;
  35106. private _localDirection;
  35107. private _volume;
  35108. private _isReadyToPlay;
  35109. private _isDirectional;
  35110. private _readyToPlayCallback;
  35111. private _audioBuffer;
  35112. private _soundSource;
  35113. private _streamingSource;
  35114. private _soundPanner;
  35115. private _soundGain;
  35116. private _inputAudioNode;
  35117. private _outputAudioNode;
  35118. private _coneInnerAngle;
  35119. private _coneOuterAngle;
  35120. private _coneOuterGain;
  35121. private _scene;
  35122. private _connectedTransformNode;
  35123. private _customAttenuationFunction;
  35124. private _registerFunc;
  35125. private _isOutputConnected;
  35126. private _htmlAudioElement;
  35127. private _urlType;
  35128. private _length?;
  35129. private _offset?;
  35130. /** @hidden */
  35131. static _SceneComponentInitialization: (scene: Scene) => void;
  35132. /**
  35133. * Create a sound and attach it to a scene
  35134. * @param name Name of your sound
  35135. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35136. * @param scene defines the scene the sound belongs to
  35137. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35138. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35139. */
  35140. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35141. /**
  35142. * Release the sound and its associated resources
  35143. */
  35144. dispose(): void;
  35145. /**
  35146. * Gets if the sounds is ready to be played or not.
  35147. * @returns true if ready, otherwise false
  35148. */
  35149. isReady(): boolean;
  35150. private _soundLoaded;
  35151. /**
  35152. * Sets the data of the sound from an audiobuffer
  35153. * @param audioBuffer The audioBuffer containing the data
  35154. */
  35155. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35156. /**
  35157. * Updates the current sounds options such as maxdistance, loop...
  35158. * @param options A JSON object containing values named as the object properties
  35159. */
  35160. updateOptions(options: ISoundOptions): void;
  35161. private _createSpatialParameters;
  35162. private _updateSpatialParameters;
  35163. /**
  35164. * Switch the panning model to HRTF:
  35165. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35166. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35167. */
  35168. switchPanningModelToHRTF(): void;
  35169. /**
  35170. * Switch the panning model to Equal Power:
  35171. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35172. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35173. */
  35174. switchPanningModelToEqualPower(): void;
  35175. private _switchPanningModel;
  35176. /**
  35177. * Connect this sound to a sound track audio node like gain...
  35178. * @param soundTrackAudioNode the sound track audio node to connect to
  35179. */
  35180. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35181. /**
  35182. * Transform this sound into a directional source
  35183. * @param coneInnerAngle Size of the inner cone in degree
  35184. * @param coneOuterAngle Size of the outer cone in degree
  35185. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35186. */
  35187. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35188. /**
  35189. * Gets or sets the inner angle for the directional cone.
  35190. */
  35191. /**
  35192. * Gets or sets the inner angle for the directional cone.
  35193. */
  35194. directionalConeInnerAngle: number;
  35195. /**
  35196. * Gets or sets the outer angle for the directional cone.
  35197. */
  35198. /**
  35199. * Gets or sets the outer angle for the directional cone.
  35200. */
  35201. directionalConeOuterAngle: number;
  35202. /**
  35203. * Sets the position of the emitter if spatial sound is enabled
  35204. * @param newPosition Defines the new posisiton
  35205. */
  35206. setPosition(newPosition: Vector3): void;
  35207. /**
  35208. * Sets the local direction of the emitter if spatial sound is enabled
  35209. * @param newLocalDirection Defines the new local direction
  35210. */
  35211. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35212. private _updateDirection;
  35213. /** @hidden */
  35214. updateDistanceFromListener(): void;
  35215. /**
  35216. * Sets a new custom attenuation function for the sound.
  35217. * @param callback Defines the function used for the attenuation
  35218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35219. */
  35220. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35221. /**
  35222. * Play the sound
  35223. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35224. * @param offset (optional) Start the sound at a specific time in seconds
  35225. * @param length (optional) Sound duration (in seconds)
  35226. */
  35227. play(time?: number, offset?: number, length?: number): void;
  35228. private _onended;
  35229. /**
  35230. * Stop the sound
  35231. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35232. */
  35233. stop(time?: number): void;
  35234. /**
  35235. * Put the sound in pause
  35236. */
  35237. pause(): void;
  35238. /**
  35239. * Sets a dedicated volume for this sounds
  35240. * @param newVolume Define the new volume of the sound
  35241. * @param time Define time for gradual change to new volume
  35242. */
  35243. setVolume(newVolume: number, time?: number): void;
  35244. /**
  35245. * Set the sound play back rate
  35246. * @param newPlaybackRate Define the playback rate the sound should be played at
  35247. */
  35248. setPlaybackRate(newPlaybackRate: number): void;
  35249. /**
  35250. * Gets the volume of the sound.
  35251. * @returns the volume of the sound
  35252. */
  35253. getVolume(): number;
  35254. /**
  35255. * Attach the sound to a dedicated mesh
  35256. * @param transformNode The transform node to connect the sound with
  35257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35258. */
  35259. attachToMesh(transformNode: TransformNode): void;
  35260. /**
  35261. * Detach the sound from the previously attached mesh
  35262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35263. */
  35264. detachFromMesh(): void;
  35265. private _onRegisterAfterWorldMatrixUpdate;
  35266. /**
  35267. * Clone the current sound in the scene.
  35268. * @returns the new sound clone
  35269. */
  35270. clone(): Nullable<Sound>;
  35271. /**
  35272. * Gets the current underlying audio buffer containing the data
  35273. * @returns the audio buffer
  35274. */
  35275. getAudioBuffer(): Nullable<AudioBuffer>;
  35276. /**
  35277. * Serializes the Sound in a JSON representation
  35278. * @returns the JSON representation of the sound
  35279. */
  35280. serialize(): any;
  35281. /**
  35282. * Parse a JSON representation of a sound to innstantiate in a given scene
  35283. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35284. * @param scene Define the scene the new parsed sound should be created in
  35285. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35286. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35287. * @returns the newly parsed sound
  35288. */
  35289. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35290. }
  35291. }
  35292. declare module BABYLON {
  35293. /**
  35294. * This defines an action helpful to play a defined sound on a triggered action.
  35295. */
  35296. export class PlaySoundAction extends Action {
  35297. private _sound;
  35298. /**
  35299. * Instantiate the action
  35300. * @param triggerOptions defines the trigger options
  35301. * @param sound defines the sound to play
  35302. * @param condition defines the trigger related conditions
  35303. */
  35304. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35305. /** @hidden */
  35306. _prepare(): void;
  35307. /**
  35308. * Execute the action and play the sound.
  35309. */
  35310. execute(): void;
  35311. /**
  35312. * Serializes the actions and its related information.
  35313. * @param parent defines the object to serialize in
  35314. * @returns the serialized object
  35315. */
  35316. serialize(parent: any): any;
  35317. }
  35318. /**
  35319. * This defines an action helpful to stop a defined sound on a triggered action.
  35320. */
  35321. export class StopSoundAction extends Action {
  35322. private _sound;
  35323. /**
  35324. * Instantiate the action
  35325. * @param triggerOptions defines the trigger options
  35326. * @param sound defines the sound to stop
  35327. * @param condition defines the trigger related conditions
  35328. */
  35329. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35330. /** @hidden */
  35331. _prepare(): void;
  35332. /**
  35333. * Execute the action and stop the sound.
  35334. */
  35335. execute(): void;
  35336. /**
  35337. * Serializes the actions and its related information.
  35338. * @param parent defines the object to serialize in
  35339. * @returns the serialized object
  35340. */
  35341. serialize(parent: any): any;
  35342. }
  35343. }
  35344. declare module BABYLON {
  35345. /**
  35346. * This defines an action responsible to change the value of a property
  35347. * by interpolating between its current value and the newly set one once triggered.
  35348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35349. */
  35350. export class InterpolateValueAction extends Action {
  35351. /**
  35352. * Defines the path of the property where the value should be interpolated
  35353. */
  35354. propertyPath: string;
  35355. /**
  35356. * Defines the target value at the end of the interpolation.
  35357. */
  35358. value: any;
  35359. /**
  35360. * Defines the time it will take for the property to interpolate to the value.
  35361. */
  35362. duration: number;
  35363. /**
  35364. * Defines if the other scene animations should be stopped when the action has been triggered
  35365. */
  35366. stopOtherAnimations?: boolean;
  35367. /**
  35368. * Defines a callback raised once the interpolation animation has been done.
  35369. */
  35370. onInterpolationDone?: () => void;
  35371. /**
  35372. * Observable triggered once the interpolation animation has been done.
  35373. */
  35374. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35375. private _target;
  35376. private _effectiveTarget;
  35377. private _property;
  35378. /**
  35379. * Instantiate the action
  35380. * @param triggerOptions defines the trigger options
  35381. * @param target defines the object containing the value to interpolate
  35382. * @param propertyPath defines the path to the property in the target object
  35383. * @param value defines the target value at the end of the interpolation
  35384. * @param duration deines the time it will take for the property to interpolate to the value.
  35385. * @param condition defines the trigger related conditions
  35386. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35387. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35388. */
  35389. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35390. /** @hidden */
  35391. _prepare(): void;
  35392. /**
  35393. * Execute the action starts the value interpolation.
  35394. */
  35395. execute(): void;
  35396. /**
  35397. * Serializes the actions and its related information.
  35398. * @param parent defines the object to serialize in
  35399. * @returns the serialized object
  35400. */
  35401. serialize(parent: any): any;
  35402. }
  35403. }
  35404. declare module BABYLON {
  35405. /**
  35406. * Options allowed during the creation of a sound track.
  35407. */
  35408. export interface ISoundTrackOptions {
  35409. /**
  35410. * The volume the sound track should take during creation
  35411. */
  35412. volume?: number;
  35413. /**
  35414. * Define if the sound track is the main sound track of the scene
  35415. */
  35416. mainTrack?: boolean;
  35417. }
  35418. /**
  35419. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35420. * It will be also used in a future release to apply effects on a specific track.
  35421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35422. */
  35423. export class SoundTrack {
  35424. /**
  35425. * The unique identifier of the sound track in the scene.
  35426. */
  35427. id: number;
  35428. /**
  35429. * The list of sounds included in the sound track.
  35430. */
  35431. soundCollection: Array<Sound>;
  35432. private _outputAudioNode;
  35433. private _scene;
  35434. private _isMainTrack;
  35435. private _connectedAnalyser;
  35436. private _options;
  35437. private _isInitialized;
  35438. /**
  35439. * Creates a new sound track.
  35440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35441. * @param scene Define the scene the sound track belongs to
  35442. * @param options
  35443. */
  35444. constructor(scene: Scene, options?: ISoundTrackOptions);
  35445. private _initializeSoundTrackAudioGraph;
  35446. /**
  35447. * Release the sound track and its associated resources
  35448. */
  35449. dispose(): void;
  35450. /**
  35451. * Adds a sound to this sound track
  35452. * @param sound define the cound to add
  35453. * @ignoreNaming
  35454. */
  35455. AddSound(sound: Sound): void;
  35456. /**
  35457. * Removes a sound to this sound track
  35458. * @param sound define the cound to remove
  35459. * @ignoreNaming
  35460. */
  35461. RemoveSound(sound: Sound): void;
  35462. /**
  35463. * Set a global volume for the full sound track.
  35464. * @param newVolume Define the new volume of the sound track
  35465. */
  35466. setVolume(newVolume: number): void;
  35467. /**
  35468. * Switch the panning model to HRTF:
  35469. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35471. */
  35472. switchPanningModelToHRTF(): void;
  35473. /**
  35474. * Switch the panning model to Equal Power:
  35475. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35477. */
  35478. switchPanningModelToEqualPower(): void;
  35479. /**
  35480. * Connect the sound track to an audio analyser allowing some amazing
  35481. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35483. * @param analyser The analyser to connect to the engine
  35484. */
  35485. connectToAnalyser(analyser: Analyser): void;
  35486. }
  35487. }
  35488. declare module BABYLON {
  35489. interface AbstractScene {
  35490. /**
  35491. * The list of sounds used in the scene.
  35492. */
  35493. sounds: Nullable<Array<Sound>>;
  35494. }
  35495. interface Scene {
  35496. /**
  35497. * @hidden
  35498. * Backing field
  35499. */
  35500. _mainSoundTrack: SoundTrack;
  35501. /**
  35502. * The main sound track played by the scene.
  35503. * It cotains your primary collection of sounds.
  35504. */
  35505. mainSoundTrack: SoundTrack;
  35506. /**
  35507. * The list of sound tracks added to the scene
  35508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35509. */
  35510. soundTracks: Nullable<Array<SoundTrack>>;
  35511. /**
  35512. * Gets a sound using a given name
  35513. * @param name defines the name to search for
  35514. * @return the found sound or null if not found at all.
  35515. */
  35516. getSoundByName(name: string): Nullable<Sound>;
  35517. /**
  35518. * Gets or sets if audio support is enabled
  35519. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35520. */
  35521. audioEnabled: boolean;
  35522. /**
  35523. * Gets or sets if audio will be output to headphones
  35524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35525. */
  35526. headphone: boolean;
  35527. /**
  35528. * Gets or sets custom audio listener position provider
  35529. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35530. */
  35531. audioListenerPositionProvider: Nullable<() => Vector3>;
  35532. }
  35533. /**
  35534. * Defines the sound scene component responsible to manage any sounds
  35535. * in a given scene.
  35536. */
  35537. export class AudioSceneComponent implements ISceneSerializableComponent {
  35538. /**
  35539. * The component name helpfull to identify the component in the list of scene components.
  35540. */
  35541. readonly name: string;
  35542. /**
  35543. * The scene the component belongs to.
  35544. */
  35545. scene: Scene;
  35546. private _audioEnabled;
  35547. /**
  35548. * Gets whether audio is enabled or not.
  35549. * Please use related enable/disable method to switch state.
  35550. */
  35551. readonly audioEnabled: boolean;
  35552. private _headphone;
  35553. /**
  35554. * Gets whether audio is outputing to headphone or not.
  35555. * Please use the according Switch methods to change output.
  35556. */
  35557. readonly headphone: boolean;
  35558. private _audioListenerPositionProvider;
  35559. /**
  35560. * Gets the current audio listener position provider
  35561. */
  35562. /**
  35563. * Sets a custom listener position for all sounds in the scene
  35564. * By default, this is the position of the first active camera
  35565. */
  35566. audioListenerPositionProvider: Nullable<() => Vector3>;
  35567. /**
  35568. * Creates a new instance of the component for the given scene
  35569. * @param scene Defines the scene to register the component in
  35570. */
  35571. constructor(scene: Scene);
  35572. /**
  35573. * Registers the component in a given scene
  35574. */
  35575. register(): void;
  35576. /**
  35577. * Rebuilds the elements related to this component in case of
  35578. * context lost for instance.
  35579. */
  35580. rebuild(): void;
  35581. /**
  35582. * Serializes the component data to the specified json object
  35583. * @param serializationObject The object to serialize to
  35584. */
  35585. serialize(serializationObject: any): void;
  35586. /**
  35587. * Adds all the elements from the container to the scene
  35588. * @param container the container holding the elements
  35589. */
  35590. addFromContainer(container: AbstractScene): void;
  35591. /**
  35592. * Removes all the elements in the container from the scene
  35593. * @param container contains the elements to remove
  35594. * @param dispose if the removed element should be disposed (default: false)
  35595. */
  35596. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35597. /**
  35598. * Disposes the component and the associated ressources.
  35599. */
  35600. dispose(): void;
  35601. /**
  35602. * Disables audio in the associated scene.
  35603. */
  35604. disableAudio(): void;
  35605. /**
  35606. * Enables audio in the associated scene.
  35607. */
  35608. enableAudio(): void;
  35609. /**
  35610. * Switch audio to headphone output.
  35611. */
  35612. switchAudioModeForHeadphones(): void;
  35613. /**
  35614. * Switch audio to normal speakers.
  35615. */
  35616. switchAudioModeForNormalSpeakers(): void;
  35617. private _afterRender;
  35618. }
  35619. }
  35620. declare module BABYLON {
  35621. /**
  35622. * Wraps one or more Sound objects and selects one with random weight for playback.
  35623. */
  35624. export class WeightedSound {
  35625. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35626. loop: boolean;
  35627. private _coneInnerAngle;
  35628. private _coneOuterAngle;
  35629. private _volume;
  35630. /** A Sound is currently playing. */
  35631. isPlaying: boolean;
  35632. /** A Sound is currently paused. */
  35633. isPaused: boolean;
  35634. private _sounds;
  35635. private _weights;
  35636. private _currentIndex?;
  35637. /**
  35638. * Creates a new WeightedSound from the list of sounds given.
  35639. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35640. * @param sounds Array of Sounds that will be selected from.
  35641. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35642. */
  35643. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35644. /**
  35645. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35646. */
  35647. /**
  35648. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35649. */
  35650. directionalConeInnerAngle: number;
  35651. /**
  35652. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35653. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35654. */
  35655. /**
  35656. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35657. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35658. */
  35659. directionalConeOuterAngle: number;
  35660. /**
  35661. * Playback volume.
  35662. */
  35663. /**
  35664. * Playback volume.
  35665. */
  35666. volume: number;
  35667. private _onended;
  35668. /**
  35669. * Suspend playback
  35670. */
  35671. pause(): void;
  35672. /**
  35673. * Stop playback
  35674. */
  35675. stop(): void;
  35676. /**
  35677. * Start playback.
  35678. * @param startOffset Position the clip head at a specific time in seconds.
  35679. */
  35680. play(startOffset?: number): void;
  35681. }
  35682. }
  35683. declare module BABYLON {
  35684. /**
  35685. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35686. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35687. */
  35688. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35689. /**
  35690. * Gets the name of the behavior.
  35691. */
  35692. readonly name: string;
  35693. /**
  35694. * The easing function used by animations
  35695. */
  35696. static EasingFunction: BackEase;
  35697. /**
  35698. * The easing mode used by animations
  35699. */
  35700. static EasingMode: number;
  35701. /**
  35702. * The duration of the animation, in milliseconds
  35703. */
  35704. transitionDuration: number;
  35705. /**
  35706. * Length of the distance animated by the transition when lower radius is reached
  35707. */
  35708. lowerRadiusTransitionRange: number;
  35709. /**
  35710. * Length of the distance animated by the transition when upper radius is reached
  35711. */
  35712. upperRadiusTransitionRange: number;
  35713. private _autoTransitionRange;
  35714. /**
  35715. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35716. */
  35717. /**
  35718. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35719. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35720. */
  35721. autoTransitionRange: boolean;
  35722. private _attachedCamera;
  35723. private _onAfterCheckInputsObserver;
  35724. private _onMeshTargetChangedObserver;
  35725. /**
  35726. * Initializes the behavior.
  35727. */
  35728. init(): void;
  35729. /**
  35730. * Attaches the behavior to its arc rotate camera.
  35731. * @param camera Defines the camera to attach the behavior to
  35732. */
  35733. attach(camera: ArcRotateCamera): void;
  35734. /**
  35735. * Detaches the behavior from its current arc rotate camera.
  35736. */
  35737. detach(): void;
  35738. private _radiusIsAnimating;
  35739. private _radiusBounceTransition;
  35740. private _animatables;
  35741. private _cachedWheelPrecision;
  35742. /**
  35743. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35744. * @param radiusLimit The limit to check against.
  35745. * @return Bool to indicate if at limit.
  35746. */
  35747. private _isRadiusAtLimit;
  35748. /**
  35749. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35750. * @param radiusDelta The delta by which to animate to. Can be negative.
  35751. */
  35752. private _applyBoundRadiusAnimation;
  35753. /**
  35754. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35755. */
  35756. protected _clearAnimationLocks(): void;
  35757. /**
  35758. * Stops and removes all animations that have been applied to the camera
  35759. */
  35760. stopAllAnimations(): void;
  35761. }
  35762. }
  35763. declare module BABYLON {
  35764. /**
  35765. * 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.
  35766. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35767. */
  35768. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35769. /**
  35770. * Gets the name of the behavior.
  35771. */
  35772. readonly name: string;
  35773. private _mode;
  35774. private _radiusScale;
  35775. private _positionScale;
  35776. private _defaultElevation;
  35777. private _elevationReturnTime;
  35778. private _elevationReturnWaitTime;
  35779. private _zoomStopsAnimation;
  35780. private _framingTime;
  35781. /**
  35782. * The easing function used by animations
  35783. */
  35784. static EasingFunction: ExponentialEase;
  35785. /**
  35786. * The easing mode used by animations
  35787. */
  35788. static EasingMode: number;
  35789. /**
  35790. * Sets the current mode used by the behavior
  35791. */
  35792. /**
  35793. * Gets current mode used by the behavior.
  35794. */
  35795. mode: number;
  35796. /**
  35797. * Sets the scale applied to the radius (1 by default)
  35798. */
  35799. /**
  35800. * Gets the scale applied to the radius
  35801. */
  35802. radiusScale: number;
  35803. /**
  35804. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35805. */
  35806. /**
  35807. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35808. */
  35809. positionScale: number;
  35810. /**
  35811. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35812. * behaviour is triggered, in radians.
  35813. */
  35814. /**
  35815. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35816. * behaviour is triggered, in radians.
  35817. */
  35818. defaultElevation: number;
  35819. /**
  35820. * Sets the time (in milliseconds) taken to return to the default beta position.
  35821. * Negative value indicates camera should not return to default.
  35822. */
  35823. /**
  35824. * Gets the time (in milliseconds) taken to return to the default beta position.
  35825. * Negative value indicates camera should not return to default.
  35826. */
  35827. elevationReturnTime: number;
  35828. /**
  35829. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35830. */
  35831. /**
  35832. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35833. */
  35834. elevationReturnWaitTime: number;
  35835. /**
  35836. * Sets the flag that indicates if user zooming should stop animation.
  35837. */
  35838. /**
  35839. * Gets the flag that indicates if user zooming should stop animation.
  35840. */
  35841. zoomStopsAnimation: boolean;
  35842. /**
  35843. * Sets the transition time when framing the mesh, in milliseconds
  35844. */
  35845. /**
  35846. * Gets the transition time when framing the mesh, in milliseconds
  35847. */
  35848. framingTime: number;
  35849. /**
  35850. * Define if the behavior should automatically change the configured
  35851. * camera limits and sensibilities.
  35852. */
  35853. autoCorrectCameraLimitsAndSensibility: boolean;
  35854. private _onPrePointerObservableObserver;
  35855. private _onAfterCheckInputsObserver;
  35856. private _onMeshTargetChangedObserver;
  35857. private _attachedCamera;
  35858. private _isPointerDown;
  35859. private _lastInteractionTime;
  35860. /**
  35861. * Initializes the behavior.
  35862. */
  35863. init(): void;
  35864. /**
  35865. * Attaches the behavior to its arc rotate camera.
  35866. * @param camera Defines the camera to attach the behavior to
  35867. */
  35868. attach(camera: ArcRotateCamera): void;
  35869. /**
  35870. * Detaches the behavior from its current arc rotate camera.
  35871. */
  35872. detach(): void;
  35873. private _animatables;
  35874. private _betaIsAnimating;
  35875. private _betaTransition;
  35876. private _radiusTransition;
  35877. private _vectorTransition;
  35878. /**
  35879. * Targets the given mesh and updates zoom level accordingly.
  35880. * @param mesh The mesh to target.
  35881. * @param radius Optional. If a cached radius position already exists, overrides default.
  35882. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35883. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35884. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35885. */
  35886. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35887. /**
  35888. * Targets the given mesh with its children and updates zoom level accordingly.
  35889. * @param mesh The mesh to target.
  35890. * @param radius Optional. If a cached radius position already exists, overrides default.
  35891. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35892. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35893. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35894. */
  35895. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35896. /**
  35897. * Targets the given meshes with their children and updates zoom level accordingly.
  35898. * @param meshes The mesh to target.
  35899. * @param radius Optional. If a cached radius position already exists, overrides default.
  35900. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35901. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35902. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35903. */
  35904. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35905. /**
  35906. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35907. * @param minimumWorld Determines the smaller position of the bounding box extend
  35908. * @param maximumWorld Determines the bigger position of the bounding box extend
  35909. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35910. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35911. */
  35912. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35913. /**
  35914. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35915. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35916. * frustum width.
  35917. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35918. * to fully enclose the mesh in the viewing frustum.
  35919. */
  35920. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35921. /**
  35922. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35923. * is automatically returned to its default position (expected to be above ground plane).
  35924. */
  35925. private _maintainCameraAboveGround;
  35926. /**
  35927. * Returns the frustum slope based on the canvas ratio and camera FOV
  35928. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35929. */
  35930. private _getFrustumSlope;
  35931. /**
  35932. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35933. */
  35934. private _clearAnimationLocks;
  35935. /**
  35936. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35937. */
  35938. private _applyUserInteraction;
  35939. /**
  35940. * Stops and removes all animations that have been applied to the camera
  35941. */
  35942. stopAllAnimations(): void;
  35943. /**
  35944. * Gets a value indicating if the user is moving the camera
  35945. */
  35946. readonly isUserIsMoving: boolean;
  35947. /**
  35948. * The camera can move all the way towards the mesh.
  35949. */
  35950. static IgnoreBoundsSizeMode: number;
  35951. /**
  35952. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35953. */
  35954. static FitFrustumSidesMode: number;
  35955. }
  35956. }
  35957. declare module BABYLON {
  35958. /**
  35959. * Base class for Camera Pointer Inputs.
  35960. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35961. * for example usage.
  35962. */
  35963. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35964. /**
  35965. * Defines the camera the input is attached to.
  35966. */
  35967. abstract camera: Camera;
  35968. /**
  35969. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35970. */
  35971. protected _altKey: boolean;
  35972. protected _ctrlKey: boolean;
  35973. protected _metaKey: boolean;
  35974. protected _shiftKey: boolean;
  35975. /**
  35976. * Which mouse buttons were pressed at time of last mouse event.
  35977. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35978. */
  35979. protected _buttonsPressed: number;
  35980. /**
  35981. * Defines the buttons associated with the input to handle camera move.
  35982. */
  35983. buttons: number[];
  35984. /**
  35985. * Attach the input controls to a specific dom element to get the input from.
  35986. * @param element Defines the element the controls should be listened from
  35987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35988. */
  35989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35990. /**
  35991. * Detach the current controls from the specified dom element.
  35992. * @param element Defines the element to stop listening the inputs from
  35993. */
  35994. detachControl(element: Nullable<HTMLElement>): void;
  35995. /**
  35996. * Gets the class name of the current input.
  35997. * @returns the class name
  35998. */
  35999. getClassName(): string;
  36000. /**
  36001. * Get the friendly name associated with the input class.
  36002. * @returns the input friendly name
  36003. */
  36004. getSimpleName(): string;
  36005. /**
  36006. * Called on pointer POINTERDOUBLETAP event.
  36007. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36008. */
  36009. protected onDoubleTap(type: string): void;
  36010. /**
  36011. * Called on pointer POINTERMOVE event if only a single touch is active.
  36012. * Override this method to provide functionality.
  36013. */
  36014. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36015. /**
  36016. * Called on pointer POINTERMOVE event if multiple touches are active.
  36017. * Override this method to provide functionality.
  36018. */
  36019. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36020. /**
  36021. * Called on JS contextmenu event.
  36022. * Override this method to provide functionality.
  36023. */
  36024. protected onContextMenu(evt: PointerEvent): void;
  36025. /**
  36026. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36027. * press.
  36028. * Override this method to provide functionality.
  36029. */
  36030. protected onButtonDown(evt: PointerEvent): void;
  36031. /**
  36032. * Called each time a new POINTERUP event occurs. Ie, for each button
  36033. * release.
  36034. * Override this method to provide functionality.
  36035. */
  36036. protected onButtonUp(evt: PointerEvent): void;
  36037. /**
  36038. * Called when window becomes inactive.
  36039. * Override this method to provide functionality.
  36040. */
  36041. protected onLostFocus(): void;
  36042. private _pointerInput;
  36043. private _observer;
  36044. private _onLostFocus;
  36045. private pointA;
  36046. private pointB;
  36047. }
  36048. }
  36049. declare module BABYLON {
  36050. /**
  36051. * Manage the pointers inputs to control an arc rotate camera.
  36052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36053. */
  36054. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36055. /**
  36056. * Defines the camera the input is attached to.
  36057. */
  36058. camera: ArcRotateCamera;
  36059. /**
  36060. * Gets the class name of the current input.
  36061. * @returns the class name
  36062. */
  36063. getClassName(): string;
  36064. /**
  36065. * Defines the buttons associated with the input to handle camera move.
  36066. */
  36067. buttons: number[];
  36068. /**
  36069. * Defines the pointer angular sensibility along the X axis or how fast is
  36070. * the camera rotating.
  36071. */
  36072. angularSensibilityX: number;
  36073. /**
  36074. * Defines the pointer angular sensibility along the Y axis or how fast is
  36075. * the camera rotating.
  36076. */
  36077. angularSensibilityY: number;
  36078. /**
  36079. * Defines the pointer pinch precision or how fast is the camera zooming.
  36080. */
  36081. pinchPrecision: number;
  36082. /**
  36083. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36084. * from 0.
  36085. * It defines the percentage of current camera.radius to use as delta when
  36086. * pinch zoom is used.
  36087. */
  36088. pinchDeltaPercentage: number;
  36089. /**
  36090. * Defines the pointer panning sensibility or how fast is the camera moving.
  36091. */
  36092. panningSensibility: number;
  36093. /**
  36094. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36095. */
  36096. multiTouchPanning: boolean;
  36097. /**
  36098. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36099. * zoom (pinch) through multitouch.
  36100. */
  36101. multiTouchPanAndZoom: boolean;
  36102. /**
  36103. * Revers pinch action direction.
  36104. */
  36105. pinchInwards: boolean;
  36106. private _isPanClick;
  36107. private _twoFingerActivityCount;
  36108. private _isPinching;
  36109. /**
  36110. * Called on pointer POINTERMOVE event if only a single touch is active.
  36111. */
  36112. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36113. /**
  36114. * Called on pointer POINTERDOUBLETAP event.
  36115. */
  36116. protected onDoubleTap(type: string): void;
  36117. /**
  36118. * Called on pointer POINTERMOVE event if multiple touches are active.
  36119. */
  36120. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36121. /**
  36122. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36123. * press.
  36124. */
  36125. protected onButtonDown(evt: PointerEvent): void;
  36126. /**
  36127. * Called each time a new POINTERUP event occurs. Ie, for each button
  36128. * release.
  36129. */
  36130. protected onButtonUp(evt: PointerEvent): void;
  36131. /**
  36132. * Called when window becomes inactive.
  36133. */
  36134. protected onLostFocus(): void;
  36135. }
  36136. }
  36137. declare module BABYLON {
  36138. /**
  36139. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36141. */
  36142. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36143. /**
  36144. * Defines the camera the input is attached to.
  36145. */
  36146. camera: ArcRotateCamera;
  36147. /**
  36148. * Defines the list of key codes associated with the up action (increase alpha)
  36149. */
  36150. keysUp: number[];
  36151. /**
  36152. * Defines the list of key codes associated with the down action (decrease alpha)
  36153. */
  36154. keysDown: number[];
  36155. /**
  36156. * Defines the list of key codes associated with the left action (increase beta)
  36157. */
  36158. keysLeft: number[];
  36159. /**
  36160. * Defines the list of key codes associated with the right action (decrease beta)
  36161. */
  36162. keysRight: number[];
  36163. /**
  36164. * Defines the list of key codes associated with the reset action.
  36165. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36166. */
  36167. keysReset: number[];
  36168. /**
  36169. * Defines the panning sensibility of the inputs.
  36170. * (How fast is the camera paning)
  36171. */
  36172. panningSensibility: number;
  36173. /**
  36174. * Defines the zooming sensibility of the inputs.
  36175. * (How fast is the camera zooming)
  36176. */
  36177. zoomingSensibility: number;
  36178. /**
  36179. * Defines wether maintaining the alt key down switch the movement mode from
  36180. * orientation to zoom.
  36181. */
  36182. useAltToZoom: boolean;
  36183. /**
  36184. * Rotation speed of the camera
  36185. */
  36186. angularSpeed: number;
  36187. private _keys;
  36188. private _ctrlPressed;
  36189. private _altPressed;
  36190. private _onCanvasBlurObserver;
  36191. private _onKeyboardObserver;
  36192. private _engine;
  36193. private _scene;
  36194. /**
  36195. * Attach the input controls to a specific dom element to get the input from.
  36196. * @param element Defines the element the controls should be listened from
  36197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36198. */
  36199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36200. /**
  36201. * Detach the current controls from the specified dom element.
  36202. * @param element Defines the element to stop listening the inputs from
  36203. */
  36204. detachControl(element: Nullable<HTMLElement>): void;
  36205. /**
  36206. * Update the current camera state depending on the inputs that have been used this frame.
  36207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36208. */
  36209. checkInputs(): void;
  36210. /**
  36211. * Gets the class name of the current intput.
  36212. * @returns the class name
  36213. */
  36214. getClassName(): string;
  36215. /**
  36216. * Get the friendly name associated with the input class.
  36217. * @returns the input friendly name
  36218. */
  36219. getSimpleName(): string;
  36220. }
  36221. }
  36222. declare module BABYLON {
  36223. /**
  36224. * Manage the mouse wheel inputs to control an arc rotate camera.
  36225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36226. */
  36227. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36228. /**
  36229. * Defines the camera the input is attached to.
  36230. */
  36231. camera: ArcRotateCamera;
  36232. /**
  36233. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36234. */
  36235. wheelPrecision: number;
  36236. /**
  36237. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36238. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36239. */
  36240. wheelDeltaPercentage: number;
  36241. private _wheel;
  36242. private _observer;
  36243. private computeDeltaFromMouseWheelLegacyEvent;
  36244. /**
  36245. * Attach the input controls to a specific dom element to get the input from.
  36246. * @param element Defines the element the controls should be listened from
  36247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36248. */
  36249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36250. /**
  36251. * Detach the current controls from the specified dom element.
  36252. * @param element Defines the element to stop listening the inputs from
  36253. */
  36254. detachControl(element: Nullable<HTMLElement>): void;
  36255. /**
  36256. * Gets the class name of the current intput.
  36257. * @returns the class name
  36258. */
  36259. getClassName(): string;
  36260. /**
  36261. * Get the friendly name associated with the input class.
  36262. * @returns the input friendly name
  36263. */
  36264. getSimpleName(): string;
  36265. }
  36266. }
  36267. declare module BABYLON {
  36268. /**
  36269. * Default Inputs manager for the ArcRotateCamera.
  36270. * It groups all the default supported inputs for ease of use.
  36271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36272. */
  36273. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36274. /**
  36275. * Instantiates a new ArcRotateCameraInputsManager.
  36276. * @param camera Defines the camera the inputs belong to
  36277. */
  36278. constructor(camera: ArcRotateCamera);
  36279. /**
  36280. * Add mouse wheel input support to the input manager.
  36281. * @returns the current input manager
  36282. */
  36283. addMouseWheel(): ArcRotateCameraInputsManager;
  36284. /**
  36285. * Add pointers input support to the input manager.
  36286. * @returns the current input manager
  36287. */
  36288. addPointers(): ArcRotateCameraInputsManager;
  36289. /**
  36290. * Add keyboard input support to the input manager.
  36291. * @returns the current input manager
  36292. */
  36293. addKeyboard(): ArcRotateCameraInputsManager;
  36294. }
  36295. }
  36296. declare module BABYLON {
  36297. /**
  36298. * This represents an orbital type of camera.
  36299. *
  36300. * 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.
  36301. * 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.
  36302. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36303. */
  36304. export class ArcRotateCamera extends TargetCamera {
  36305. /**
  36306. * Defines the rotation angle of the camera along the longitudinal axis.
  36307. */
  36308. alpha: number;
  36309. /**
  36310. * Defines the rotation angle of the camera along the latitudinal axis.
  36311. */
  36312. beta: number;
  36313. /**
  36314. * Defines the radius of the camera from it s target point.
  36315. */
  36316. radius: number;
  36317. protected _target: Vector3;
  36318. protected _targetHost: Nullable<AbstractMesh>;
  36319. /**
  36320. * Defines the target point of the camera.
  36321. * The camera looks towards it form the radius distance.
  36322. */
  36323. target: Vector3;
  36324. /**
  36325. * Define the current local position of the camera in the scene
  36326. */
  36327. position: Vector3;
  36328. protected _upVector: Vector3;
  36329. protected _upToYMatrix: Matrix;
  36330. protected _YToUpMatrix: Matrix;
  36331. /**
  36332. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36333. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36334. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36335. */
  36336. upVector: Vector3;
  36337. /**
  36338. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36339. */
  36340. setMatUp(): void;
  36341. /**
  36342. * Current inertia value on the longitudinal axis.
  36343. * The bigger this number the longer it will take for the camera to stop.
  36344. */
  36345. inertialAlphaOffset: number;
  36346. /**
  36347. * Current inertia value on the latitudinal axis.
  36348. * The bigger this number the longer it will take for the camera to stop.
  36349. */
  36350. inertialBetaOffset: number;
  36351. /**
  36352. * Current inertia value on the radius axis.
  36353. * The bigger this number the longer it will take for the camera to stop.
  36354. */
  36355. inertialRadiusOffset: number;
  36356. /**
  36357. * Minimum allowed angle on the longitudinal axis.
  36358. * This can help limiting how the Camera is able to move in the scene.
  36359. */
  36360. lowerAlphaLimit: Nullable<number>;
  36361. /**
  36362. * Maximum allowed angle on the longitudinal axis.
  36363. * This can help limiting how the Camera is able to move in the scene.
  36364. */
  36365. upperAlphaLimit: Nullable<number>;
  36366. /**
  36367. * Minimum allowed angle on the latitudinal axis.
  36368. * This can help limiting how the Camera is able to move in the scene.
  36369. */
  36370. lowerBetaLimit: number;
  36371. /**
  36372. * Maximum allowed angle on the latitudinal axis.
  36373. * This can help limiting how the Camera is able to move in the scene.
  36374. */
  36375. upperBetaLimit: number;
  36376. /**
  36377. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36378. * This can help limiting how the Camera is able to move in the scene.
  36379. */
  36380. lowerRadiusLimit: Nullable<number>;
  36381. /**
  36382. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36383. * This can help limiting how the Camera is able to move in the scene.
  36384. */
  36385. upperRadiusLimit: Nullable<number>;
  36386. /**
  36387. * Defines the current inertia value used during panning of the camera along the X axis.
  36388. */
  36389. inertialPanningX: number;
  36390. /**
  36391. * Defines the current inertia value used during panning of the camera along the Y axis.
  36392. */
  36393. inertialPanningY: number;
  36394. /**
  36395. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36396. * Basically if your fingers moves away from more than this distance you will be considered
  36397. * in pinch mode.
  36398. */
  36399. pinchToPanMaxDistance: number;
  36400. /**
  36401. * Defines the maximum distance the camera can pan.
  36402. * This could help keeping the cammera always in your scene.
  36403. */
  36404. panningDistanceLimit: Nullable<number>;
  36405. /**
  36406. * Defines the target of the camera before paning.
  36407. */
  36408. panningOriginTarget: Vector3;
  36409. /**
  36410. * Defines the value of the inertia used during panning.
  36411. * 0 would mean stop inertia and one would mean no decelleration at all.
  36412. */
  36413. panningInertia: number;
  36414. /**
  36415. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36416. */
  36417. angularSensibilityX: number;
  36418. /**
  36419. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36420. */
  36421. angularSensibilityY: number;
  36422. /**
  36423. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36424. */
  36425. pinchPrecision: number;
  36426. /**
  36427. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36428. * It will be used instead of pinchDeltaPrecision if different from 0.
  36429. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36430. */
  36431. pinchDeltaPercentage: number;
  36432. /**
  36433. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36434. */
  36435. panningSensibility: number;
  36436. /**
  36437. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36438. */
  36439. keysUp: number[];
  36440. /**
  36441. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36442. */
  36443. keysDown: number[];
  36444. /**
  36445. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36446. */
  36447. keysLeft: number[];
  36448. /**
  36449. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36450. */
  36451. keysRight: number[];
  36452. /**
  36453. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36454. */
  36455. wheelPrecision: number;
  36456. /**
  36457. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36458. * It will be used instead of pinchDeltaPrecision if different from 0.
  36459. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36460. */
  36461. wheelDeltaPercentage: number;
  36462. /**
  36463. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36464. */
  36465. zoomOnFactor: number;
  36466. /**
  36467. * Defines a screen offset for the camera position.
  36468. */
  36469. targetScreenOffset: Vector2;
  36470. /**
  36471. * Allows the camera to be completely reversed.
  36472. * If false the camera can not arrive upside down.
  36473. */
  36474. allowUpsideDown: boolean;
  36475. /**
  36476. * Define if double tap/click is used to restore the previously saved state of the camera.
  36477. */
  36478. useInputToRestoreState: boolean;
  36479. /** @hidden */
  36480. _viewMatrix: Matrix;
  36481. /** @hidden */
  36482. _useCtrlForPanning: boolean;
  36483. /** @hidden */
  36484. _panningMouseButton: number;
  36485. /**
  36486. * Defines the input associated to the camera.
  36487. */
  36488. inputs: ArcRotateCameraInputsManager;
  36489. /** @hidden */
  36490. _reset: () => void;
  36491. /**
  36492. * Defines the allowed panning axis.
  36493. */
  36494. panningAxis: Vector3;
  36495. protected _localDirection: Vector3;
  36496. protected _transformedDirection: Vector3;
  36497. private _bouncingBehavior;
  36498. /**
  36499. * Gets the bouncing behavior of the camera if it has been enabled.
  36500. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36501. */
  36502. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36503. /**
  36504. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36505. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36506. */
  36507. useBouncingBehavior: boolean;
  36508. private _framingBehavior;
  36509. /**
  36510. * Gets the framing behavior of the camera if it has been enabled.
  36511. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36512. */
  36513. readonly framingBehavior: Nullable<FramingBehavior>;
  36514. /**
  36515. * Defines if the framing behavior of the camera is enabled on the camera.
  36516. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36517. */
  36518. useFramingBehavior: boolean;
  36519. private _autoRotationBehavior;
  36520. /**
  36521. * Gets the auto rotation behavior of the camera if it has been enabled.
  36522. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36523. */
  36524. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36525. /**
  36526. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36527. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36528. */
  36529. useAutoRotationBehavior: boolean;
  36530. /**
  36531. * Observable triggered when the mesh target has been changed on the camera.
  36532. */
  36533. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36534. /**
  36535. * Event raised when the camera is colliding with a mesh.
  36536. */
  36537. onCollide: (collidedMesh: AbstractMesh) => void;
  36538. /**
  36539. * Defines whether the camera should check collision with the objects oh the scene.
  36540. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36541. */
  36542. checkCollisions: boolean;
  36543. /**
  36544. * Defines the collision radius of the camera.
  36545. * This simulates a sphere around the camera.
  36546. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36547. */
  36548. collisionRadius: Vector3;
  36549. protected _collider: Collider;
  36550. protected _previousPosition: Vector3;
  36551. protected _collisionVelocity: Vector3;
  36552. protected _newPosition: Vector3;
  36553. protected _previousAlpha: number;
  36554. protected _previousBeta: number;
  36555. protected _previousRadius: number;
  36556. protected _collisionTriggered: boolean;
  36557. protected _targetBoundingCenter: Nullable<Vector3>;
  36558. private _computationVector;
  36559. /**
  36560. * Instantiates a new ArcRotateCamera in a given scene
  36561. * @param name Defines the name of the camera
  36562. * @param alpha Defines the camera rotation along the logitudinal axis
  36563. * @param beta Defines the camera rotation along the latitudinal axis
  36564. * @param radius Defines the camera distance from its target
  36565. * @param target Defines the camera target
  36566. * @param scene Defines the scene the camera belongs to
  36567. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36568. */
  36569. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36570. /** @hidden */
  36571. _initCache(): void;
  36572. /** @hidden */
  36573. _updateCache(ignoreParentClass?: boolean): void;
  36574. protected _getTargetPosition(): Vector3;
  36575. private _storedAlpha;
  36576. private _storedBeta;
  36577. private _storedRadius;
  36578. private _storedTarget;
  36579. private _storedTargetScreenOffset;
  36580. /**
  36581. * Stores the current state of the camera (alpha, beta, radius and target)
  36582. * @returns the camera itself
  36583. */
  36584. storeState(): Camera;
  36585. /**
  36586. * @hidden
  36587. * Restored camera state. You must call storeState() first
  36588. */
  36589. _restoreStateValues(): boolean;
  36590. /** @hidden */
  36591. _isSynchronizedViewMatrix(): boolean;
  36592. /**
  36593. * Attached controls to the current camera.
  36594. * @param element Defines the element the controls should be listened from
  36595. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36596. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36597. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36598. */
  36599. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36600. /**
  36601. * Detach the current controls from the camera.
  36602. * The camera will stop reacting to inputs.
  36603. * @param element Defines the element to stop listening the inputs from
  36604. */
  36605. detachControl(element: HTMLElement): void;
  36606. /** @hidden */
  36607. _checkInputs(): void;
  36608. protected _checkLimits(): void;
  36609. /**
  36610. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36611. */
  36612. rebuildAnglesAndRadius(): void;
  36613. /**
  36614. * Use a position to define the current camera related information like aplha, beta and radius
  36615. * @param position Defines the position to set the camera at
  36616. */
  36617. setPosition(position: Vector3): void;
  36618. /**
  36619. * Defines the target the camera should look at.
  36620. * This will automatically adapt alpha beta and radius to fit within the new target.
  36621. * @param target Defines the new target as a Vector or a mesh
  36622. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36623. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36624. */
  36625. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36626. /** @hidden */
  36627. _getViewMatrix(): Matrix;
  36628. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36629. /**
  36630. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36631. * @param meshes Defines the mesh to zoom on
  36632. * @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)
  36633. */
  36634. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36635. /**
  36636. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36637. * The target will be changed but the radius
  36638. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36639. * @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)
  36640. */
  36641. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36642. min: Vector3;
  36643. max: Vector3;
  36644. distance: number;
  36645. }, doNotUpdateMaxZ?: boolean): void;
  36646. /**
  36647. * @override
  36648. * Override Camera.createRigCamera
  36649. */
  36650. createRigCamera(name: string, cameraIndex: number): Camera;
  36651. /**
  36652. * @hidden
  36653. * @override
  36654. * Override Camera._updateRigCameras
  36655. */
  36656. _updateRigCameras(): void;
  36657. /**
  36658. * Destroy the camera and release the current resources hold by it.
  36659. */
  36660. dispose(): void;
  36661. /**
  36662. * Gets the current object class name.
  36663. * @return the class name
  36664. */
  36665. getClassName(): string;
  36666. }
  36667. }
  36668. declare module BABYLON {
  36669. /**
  36670. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36672. */
  36673. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36674. /**
  36675. * Gets the name of the behavior.
  36676. */
  36677. readonly name: string;
  36678. private _zoomStopsAnimation;
  36679. private _idleRotationSpeed;
  36680. private _idleRotationWaitTime;
  36681. private _idleRotationSpinupTime;
  36682. /**
  36683. * Sets the flag that indicates if user zooming should stop animation.
  36684. */
  36685. /**
  36686. * Gets the flag that indicates if user zooming should stop animation.
  36687. */
  36688. zoomStopsAnimation: boolean;
  36689. /**
  36690. * Sets the default speed at which the camera rotates around the model.
  36691. */
  36692. /**
  36693. * Gets the default speed at which the camera rotates around the model.
  36694. */
  36695. idleRotationSpeed: number;
  36696. /**
  36697. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36698. */
  36699. /**
  36700. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36701. */
  36702. idleRotationWaitTime: number;
  36703. /**
  36704. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36705. */
  36706. /**
  36707. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36708. */
  36709. idleRotationSpinupTime: number;
  36710. /**
  36711. * Gets a value indicating if the camera is currently rotating because of this behavior
  36712. */
  36713. readonly rotationInProgress: boolean;
  36714. private _onPrePointerObservableObserver;
  36715. private _onAfterCheckInputsObserver;
  36716. private _attachedCamera;
  36717. private _isPointerDown;
  36718. private _lastFrameTime;
  36719. private _lastInteractionTime;
  36720. private _cameraRotationSpeed;
  36721. /**
  36722. * Initializes the behavior.
  36723. */
  36724. init(): void;
  36725. /**
  36726. * Attaches the behavior to its arc rotate camera.
  36727. * @param camera Defines the camera to attach the behavior to
  36728. */
  36729. attach(camera: ArcRotateCamera): void;
  36730. /**
  36731. * Detaches the behavior from its current arc rotate camera.
  36732. */
  36733. detach(): void;
  36734. /**
  36735. * Returns true if user is scrolling.
  36736. * @return true if user is scrolling.
  36737. */
  36738. private _userIsZooming;
  36739. private _lastFrameRadius;
  36740. private _shouldAnimationStopForInteraction;
  36741. /**
  36742. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36743. */
  36744. private _applyUserInteraction;
  36745. private _userIsMoving;
  36746. }
  36747. }
  36748. declare module BABYLON {
  36749. /**
  36750. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36751. */
  36752. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36753. private ui;
  36754. /**
  36755. * The name of the behavior
  36756. */
  36757. name: string;
  36758. /**
  36759. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36760. */
  36761. distanceAwayFromFace: number;
  36762. /**
  36763. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36764. */
  36765. distanceAwayFromBottomOfFace: number;
  36766. private _faceVectors;
  36767. private _target;
  36768. private _scene;
  36769. private _onRenderObserver;
  36770. private _tmpMatrix;
  36771. private _tmpVector;
  36772. /**
  36773. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36774. * @param ui The transform node that should be attched to the mesh
  36775. */
  36776. constructor(ui: TransformNode);
  36777. /**
  36778. * Initializes the behavior
  36779. */
  36780. init(): void;
  36781. private _closestFace;
  36782. private _zeroVector;
  36783. private _lookAtTmpMatrix;
  36784. private _lookAtToRef;
  36785. /**
  36786. * Attaches the AttachToBoxBehavior to the passed in mesh
  36787. * @param target The mesh that the specified node will be attached to
  36788. */
  36789. attach(target: Mesh): void;
  36790. /**
  36791. * Detaches the behavior from the mesh
  36792. */
  36793. detach(): void;
  36794. }
  36795. }
  36796. declare module BABYLON {
  36797. /**
  36798. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36799. */
  36800. export class FadeInOutBehavior implements Behavior<Mesh> {
  36801. /**
  36802. * Time in milliseconds to delay before fading in (Default: 0)
  36803. */
  36804. delay: number;
  36805. /**
  36806. * Time in milliseconds for the mesh to fade in (Default: 300)
  36807. */
  36808. fadeInTime: number;
  36809. private _millisecondsPerFrame;
  36810. private _hovered;
  36811. private _hoverValue;
  36812. private _ownerNode;
  36813. /**
  36814. * Instatiates the FadeInOutBehavior
  36815. */
  36816. constructor();
  36817. /**
  36818. * The name of the behavior
  36819. */
  36820. readonly name: string;
  36821. /**
  36822. * Initializes the behavior
  36823. */
  36824. init(): void;
  36825. /**
  36826. * Attaches the fade behavior on the passed in mesh
  36827. * @param ownerNode The mesh that will be faded in/out once attached
  36828. */
  36829. attach(ownerNode: Mesh): void;
  36830. /**
  36831. * Detaches the behavior from the mesh
  36832. */
  36833. detach(): void;
  36834. /**
  36835. * Triggers the mesh to begin fading in or out
  36836. * @param value if the object should fade in or out (true to fade in)
  36837. */
  36838. fadeIn(value: boolean): void;
  36839. private _update;
  36840. private _setAllVisibility;
  36841. }
  36842. }
  36843. declare module BABYLON {
  36844. /**
  36845. * Class containing a set of static utilities functions for managing Pivots
  36846. * @hidden
  36847. */
  36848. export class PivotTools {
  36849. private static _PivotCached;
  36850. private static _OldPivotPoint;
  36851. private static _PivotTranslation;
  36852. private static _PivotTmpVector;
  36853. /** @hidden */
  36854. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36855. /** @hidden */
  36856. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36857. }
  36858. }
  36859. declare module BABYLON {
  36860. /**
  36861. * Class containing static functions to help procedurally build meshes
  36862. */
  36863. export class PlaneBuilder {
  36864. /**
  36865. * Creates a plane mesh
  36866. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36867. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36868. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36870. * * 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
  36871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36872. * @param name defines the name of the mesh
  36873. * @param options defines the options used to create the mesh
  36874. * @param scene defines the hosting scene
  36875. * @returns the plane mesh
  36876. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36877. */
  36878. static CreatePlane(name: string, options: {
  36879. size?: number;
  36880. width?: number;
  36881. height?: number;
  36882. sideOrientation?: number;
  36883. frontUVs?: Vector4;
  36884. backUVs?: Vector4;
  36885. updatable?: boolean;
  36886. sourcePlane?: Plane;
  36887. }, scene?: Nullable<Scene>): Mesh;
  36888. }
  36889. }
  36890. declare module BABYLON {
  36891. /**
  36892. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36893. */
  36894. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36895. private static _AnyMouseID;
  36896. /**
  36897. * Abstract mesh the behavior is set on
  36898. */
  36899. attachedNode: AbstractMesh;
  36900. private _dragPlane;
  36901. private _scene;
  36902. private _pointerObserver;
  36903. private _beforeRenderObserver;
  36904. private static _planeScene;
  36905. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36906. /**
  36907. * 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)
  36908. */
  36909. maxDragAngle: number;
  36910. /**
  36911. * @hidden
  36912. */
  36913. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36914. /**
  36915. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36916. */
  36917. currentDraggingPointerID: number;
  36918. /**
  36919. * The last position where the pointer hit the drag plane in world space
  36920. */
  36921. lastDragPosition: Vector3;
  36922. /**
  36923. * If the behavior is currently in a dragging state
  36924. */
  36925. dragging: boolean;
  36926. /**
  36927. * 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)
  36928. */
  36929. dragDeltaRatio: number;
  36930. /**
  36931. * If the drag plane orientation should be updated during the dragging (Default: true)
  36932. */
  36933. updateDragPlane: boolean;
  36934. private _debugMode;
  36935. private _moving;
  36936. /**
  36937. * Fires each time the attached mesh is dragged with the pointer
  36938. * * delta between last drag position and current drag position in world space
  36939. * * dragDistance along the drag axis
  36940. * * dragPlaneNormal normal of the current drag plane used during the drag
  36941. * * dragPlanePoint in world space where the drag intersects the drag plane
  36942. */
  36943. onDragObservable: Observable<{
  36944. delta: Vector3;
  36945. dragPlanePoint: Vector3;
  36946. dragPlaneNormal: Vector3;
  36947. dragDistance: number;
  36948. pointerId: number;
  36949. }>;
  36950. /**
  36951. * Fires each time a drag begins (eg. mouse down on mesh)
  36952. */
  36953. onDragStartObservable: Observable<{
  36954. dragPlanePoint: Vector3;
  36955. pointerId: number;
  36956. }>;
  36957. /**
  36958. * Fires each time a drag ends (eg. mouse release after drag)
  36959. */
  36960. onDragEndObservable: Observable<{
  36961. dragPlanePoint: Vector3;
  36962. pointerId: number;
  36963. }>;
  36964. /**
  36965. * If the attached mesh should be moved when dragged
  36966. */
  36967. moveAttached: boolean;
  36968. /**
  36969. * If the drag behavior will react to drag events (Default: true)
  36970. */
  36971. enabled: boolean;
  36972. /**
  36973. * If pointer events should start and release the drag (Default: true)
  36974. */
  36975. startAndReleaseDragOnPointerEvents: boolean;
  36976. /**
  36977. * If camera controls should be detached during the drag
  36978. */
  36979. detachCameraControls: boolean;
  36980. /**
  36981. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36982. */
  36983. useObjectOrienationForDragging: boolean;
  36984. private _options;
  36985. /**
  36986. * Creates a pointer drag behavior that can be attached to a mesh
  36987. * @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)
  36988. */
  36989. constructor(options?: {
  36990. dragAxis?: Vector3;
  36991. dragPlaneNormal?: Vector3;
  36992. });
  36993. /**
  36994. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36995. */
  36996. validateDrag: (targetPosition: Vector3) => boolean;
  36997. /**
  36998. * The name of the behavior
  36999. */
  37000. readonly name: string;
  37001. /**
  37002. * Initializes the behavior
  37003. */
  37004. init(): void;
  37005. private _tmpVector;
  37006. private _alternatePickedPoint;
  37007. private _worldDragAxis;
  37008. private _targetPosition;
  37009. private _attachedElement;
  37010. /**
  37011. * Attaches the drag behavior the passed in mesh
  37012. * @param ownerNode The mesh that will be dragged around once attached
  37013. * @param predicate Predicate to use for pick filtering
  37014. */
  37015. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37016. /**
  37017. * Force relase the drag action by code.
  37018. */
  37019. releaseDrag(): void;
  37020. private _startDragRay;
  37021. private _lastPointerRay;
  37022. /**
  37023. * Simulates the start of a pointer drag event on the behavior
  37024. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37025. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37026. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37027. */
  37028. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37029. private _startDrag;
  37030. private _dragDelta;
  37031. private _moveDrag;
  37032. private _pickWithRayOnDragPlane;
  37033. private _pointA;
  37034. private _pointB;
  37035. private _pointC;
  37036. private _lineA;
  37037. private _lineB;
  37038. private _localAxis;
  37039. private _lookAt;
  37040. private _updateDragPlanePosition;
  37041. /**
  37042. * Detaches the behavior from the mesh
  37043. */
  37044. detach(): void;
  37045. }
  37046. }
  37047. declare module BABYLON {
  37048. /**
  37049. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37050. */
  37051. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37052. private _dragBehaviorA;
  37053. private _dragBehaviorB;
  37054. private _startDistance;
  37055. private _initialScale;
  37056. private _targetScale;
  37057. private _ownerNode;
  37058. private _sceneRenderObserver;
  37059. /**
  37060. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37061. */
  37062. constructor();
  37063. /**
  37064. * The name of the behavior
  37065. */
  37066. readonly name: string;
  37067. /**
  37068. * Initializes the behavior
  37069. */
  37070. init(): void;
  37071. private _getCurrentDistance;
  37072. /**
  37073. * Attaches the scale behavior the passed in mesh
  37074. * @param ownerNode The mesh that will be scaled around once attached
  37075. */
  37076. attach(ownerNode: Mesh): void;
  37077. /**
  37078. * Detaches the behavior from the mesh
  37079. */
  37080. detach(): void;
  37081. }
  37082. }
  37083. declare module BABYLON {
  37084. /**
  37085. * 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
  37086. */
  37087. export class SixDofDragBehavior implements Behavior<Mesh> {
  37088. private static _virtualScene;
  37089. private _ownerNode;
  37090. private _sceneRenderObserver;
  37091. private _scene;
  37092. private _targetPosition;
  37093. private _virtualOriginMesh;
  37094. private _virtualDragMesh;
  37095. private _pointerObserver;
  37096. private _moving;
  37097. private _startingOrientation;
  37098. /**
  37099. * 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)
  37100. */
  37101. private zDragFactor;
  37102. /**
  37103. * If the object should rotate to face the drag origin
  37104. */
  37105. rotateDraggedObject: boolean;
  37106. /**
  37107. * If the behavior is currently in a dragging state
  37108. */
  37109. dragging: boolean;
  37110. /**
  37111. * 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)
  37112. */
  37113. dragDeltaRatio: number;
  37114. /**
  37115. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37116. */
  37117. currentDraggingPointerID: number;
  37118. /**
  37119. * If camera controls should be detached during the drag
  37120. */
  37121. detachCameraControls: boolean;
  37122. /**
  37123. * Fires each time a drag starts
  37124. */
  37125. onDragStartObservable: Observable<{}>;
  37126. /**
  37127. * Fires each time a drag ends (eg. mouse release after drag)
  37128. */
  37129. onDragEndObservable: Observable<{}>;
  37130. /**
  37131. * 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
  37132. */
  37133. constructor();
  37134. /**
  37135. * The name of the behavior
  37136. */
  37137. readonly name: string;
  37138. /**
  37139. * Initializes the behavior
  37140. */
  37141. init(): void;
  37142. /**
  37143. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37144. */
  37145. private readonly _pointerCamera;
  37146. /**
  37147. * Attaches the scale behavior the passed in mesh
  37148. * @param ownerNode The mesh that will be scaled around once attached
  37149. */
  37150. attach(ownerNode: Mesh): void;
  37151. /**
  37152. * Detaches the behavior from the mesh
  37153. */
  37154. detach(): void;
  37155. }
  37156. }
  37157. declare module BABYLON {
  37158. /**
  37159. * Class used to apply inverse kinematics to bones
  37160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37161. */
  37162. export class BoneIKController {
  37163. private static _tmpVecs;
  37164. private static _tmpQuat;
  37165. private static _tmpMats;
  37166. /**
  37167. * Gets or sets the target mesh
  37168. */
  37169. targetMesh: AbstractMesh;
  37170. /** Gets or sets the mesh used as pole */
  37171. poleTargetMesh: AbstractMesh;
  37172. /**
  37173. * Gets or sets the bone used as pole
  37174. */
  37175. poleTargetBone: Nullable<Bone>;
  37176. /**
  37177. * Gets or sets the target position
  37178. */
  37179. targetPosition: Vector3;
  37180. /**
  37181. * Gets or sets the pole target position
  37182. */
  37183. poleTargetPosition: Vector3;
  37184. /**
  37185. * Gets or sets the pole target local offset
  37186. */
  37187. poleTargetLocalOffset: Vector3;
  37188. /**
  37189. * Gets or sets the pole angle
  37190. */
  37191. poleAngle: number;
  37192. /**
  37193. * Gets or sets the mesh associated with the controller
  37194. */
  37195. mesh: AbstractMesh;
  37196. /**
  37197. * 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)
  37198. */
  37199. slerpAmount: number;
  37200. private _bone1Quat;
  37201. private _bone1Mat;
  37202. private _bone2Ang;
  37203. private _bone1;
  37204. private _bone2;
  37205. private _bone1Length;
  37206. private _bone2Length;
  37207. private _maxAngle;
  37208. private _maxReach;
  37209. private _rightHandedSystem;
  37210. private _bendAxis;
  37211. private _slerping;
  37212. private _adjustRoll;
  37213. /**
  37214. * Gets or sets maximum allowed angle
  37215. */
  37216. maxAngle: number;
  37217. /**
  37218. * Creates a new BoneIKController
  37219. * @param mesh defines the mesh to control
  37220. * @param bone defines the bone to control
  37221. * @param options defines options to set up the controller
  37222. */
  37223. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37224. targetMesh?: AbstractMesh;
  37225. poleTargetMesh?: AbstractMesh;
  37226. poleTargetBone?: Bone;
  37227. poleTargetLocalOffset?: Vector3;
  37228. poleAngle?: number;
  37229. bendAxis?: Vector3;
  37230. maxAngle?: number;
  37231. slerpAmount?: number;
  37232. });
  37233. private _setMaxAngle;
  37234. /**
  37235. * Force the controller to update the bones
  37236. */
  37237. update(): void;
  37238. }
  37239. }
  37240. declare module BABYLON {
  37241. /**
  37242. * Class used to make a bone look toward a point in space
  37243. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37244. */
  37245. export class BoneLookController {
  37246. private static _tmpVecs;
  37247. private static _tmpQuat;
  37248. private static _tmpMats;
  37249. /**
  37250. * The target Vector3 that the bone will look at
  37251. */
  37252. target: Vector3;
  37253. /**
  37254. * The mesh that the bone is attached to
  37255. */
  37256. mesh: AbstractMesh;
  37257. /**
  37258. * The bone that will be looking to the target
  37259. */
  37260. bone: Bone;
  37261. /**
  37262. * The up axis of the coordinate system that is used when the bone is rotated
  37263. */
  37264. upAxis: Vector3;
  37265. /**
  37266. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37267. */
  37268. upAxisSpace: Space;
  37269. /**
  37270. * Used to make an adjustment to the yaw of the bone
  37271. */
  37272. adjustYaw: number;
  37273. /**
  37274. * Used to make an adjustment to the pitch of the bone
  37275. */
  37276. adjustPitch: number;
  37277. /**
  37278. * Used to make an adjustment to the roll of the bone
  37279. */
  37280. adjustRoll: number;
  37281. /**
  37282. * 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)
  37283. */
  37284. slerpAmount: number;
  37285. private _minYaw;
  37286. private _maxYaw;
  37287. private _minPitch;
  37288. private _maxPitch;
  37289. private _minYawSin;
  37290. private _minYawCos;
  37291. private _maxYawSin;
  37292. private _maxYawCos;
  37293. private _midYawConstraint;
  37294. private _minPitchTan;
  37295. private _maxPitchTan;
  37296. private _boneQuat;
  37297. private _slerping;
  37298. private _transformYawPitch;
  37299. private _transformYawPitchInv;
  37300. private _firstFrameSkipped;
  37301. private _yawRange;
  37302. private _fowardAxis;
  37303. /**
  37304. * Gets or sets the minimum yaw angle that the bone can look to
  37305. */
  37306. minYaw: number;
  37307. /**
  37308. * Gets or sets the maximum yaw angle that the bone can look to
  37309. */
  37310. maxYaw: number;
  37311. /**
  37312. * Gets or sets the minimum pitch angle that the bone can look to
  37313. */
  37314. minPitch: number;
  37315. /**
  37316. * Gets or sets the maximum pitch angle that the bone can look to
  37317. */
  37318. maxPitch: number;
  37319. /**
  37320. * Create a BoneLookController
  37321. * @param mesh the mesh that the bone belongs to
  37322. * @param bone the bone that will be looking to the target
  37323. * @param target the target Vector3 to look at
  37324. * @param options optional settings:
  37325. * * maxYaw: the maximum angle the bone will yaw to
  37326. * * minYaw: the minimum angle the bone will yaw to
  37327. * * maxPitch: the maximum angle the bone will pitch to
  37328. * * minPitch: the minimum angle the bone will yaw to
  37329. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37330. * * upAxis: the up axis of the coordinate system
  37331. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37332. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37333. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37334. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37335. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37336. * * adjustRoll: used to make an adjustment to the roll of the bone
  37337. **/
  37338. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37339. maxYaw?: number;
  37340. minYaw?: number;
  37341. maxPitch?: number;
  37342. minPitch?: number;
  37343. slerpAmount?: number;
  37344. upAxis?: Vector3;
  37345. upAxisSpace?: Space;
  37346. yawAxis?: Vector3;
  37347. pitchAxis?: Vector3;
  37348. adjustYaw?: number;
  37349. adjustPitch?: number;
  37350. adjustRoll?: number;
  37351. });
  37352. /**
  37353. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37354. */
  37355. update(): void;
  37356. private _getAngleDiff;
  37357. private _getAngleBetween;
  37358. private _isAngleBetween;
  37359. }
  37360. }
  37361. declare module BABYLON {
  37362. /**
  37363. * Manage the gamepad inputs to control an arc rotate camera.
  37364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37365. */
  37366. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37367. /**
  37368. * Defines the camera the input is attached to.
  37369. */
  37370. camera: ArcRotateCamera;
  37371. /**
  37372. * Defines the gamepad the input is gathering event from.
  37373. */
  37374. gamepad: Nullable<Gamepad>;
  37375. /**
  37376. * Defines the gamepad rotation sensiblity.
  37377. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37378. */
  37379. gamepadRotationSensibility: number;
  37380. /**
  37381. * Defines the gamepad move sensiblity.
  37382. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37383. */
  37384. gamepadMoveSensibility: number;
  37385. private _onGamepadConnectedObserver;
  37386. private _onGamepadDisconnectedObserver;
  37387. /**
  37388. * Attach the input controls to a specific dom element to get the input from.
  37389. * @param element Defines the element the controls should be listened from
  37390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37391. */
  37392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37393. /**
  37394. * Detach the current controls from the specified dom element.
  37395. * @param element Defines the element to stop listening the inputs from
  37396. */
  37397. detachControl(element: Nullable<HTMLElement>): void;
  37398. /**
  37399. * Update the current camera state depending on the inputs that have been used this frame.
  37400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37401. */
  37402. checkInputs(): void;
  37403. /**
  37404. * Gets the class name of the current intput.
  37405. * @returns the class name
  37406. */
  37407. getClassName(): string;
  37408. /**
  37409. * Get the friendly name associated with the input class.
  37410. * @returns the input friendly name
  37411. */
  37412. getSimpleName(): string;
  37413. }
  37414. }
  37415. declare module BABYLON {
  37416. interface ArcRotateCameraInputsManager {
  37417. /**
  37418. * Add orientation input support to the input manager.
  37419. * @returns the current input manager
  37420. */
  37421. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37422. }
  37423. /**
  37424. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37426. */
  37427. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37428. /**
  37429. * Defines the camera the input is attached to.
  37430. */
  37431. camera: ArcRotateCamera;
  37432. /**
  37433. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37434. */
  37435. alphaCorrection: number;
  37436. /**
  37437. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37438. */
  37439. gammaCorrection: number;
  37440. private _alpha;
  37441. private _gamma;
  37442. private _dirty;
  37443. private _deviceOrientationHandler;
  37444. /**
  37445. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37446. */
  37447. constructor();
  37448. /**
  37449. * Attach the input controls to a specific dom element to get the input from.
  37450. * @param element Defines the element the controls should be listened from
  37451. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37452. */
  37453. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37454. /** @hidden */
  37455. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37456. /**
  37457. * Update the current camera state depending on the inputs that have been used this frame.
  37458. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37459. */
  37460. checkInputs(): void;
  37461. /**
  37462. * Detach the current controls from the specified dom element.
  37463. * @param element Defines the element to stop listening the inputs from
  37464. */
  37465. detachControl(element: Nullable<HTMLElement>): void;
  37466. /**
  37467. * Gets the class name of the current intput.
  37468. * @returns the class name
  37469. */
  37470. getClassName(): string;
  37471. /**
  37472. * Get the friendly name associated with the input class.
  37473. * @returns the input friendly name
  37474. */
  37475. getSimpleName(): string;
  37476. }
  37477. }
  37478. declare module BABYLON {
  37479. /**
  37480. * Listen to mouse events to control the camera.
  37481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37482. */
  37483. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37484. /**
  37485. * Defines the camera the input is attached to.
  37486. */
  37487. camera: FlyCamera;
  37488. /**
  37489. * Defines if touch is enabled. (Default is true.)
  37490. */
  37491. touchEnabled: boolean;
  37492. /**
  37493. * Defines the buttons associated with the input to handle camera rotation.
  37494. */
  37495. buttons: number[];
  37496. /**
  37497. * Assign buttons for Yaw control.
  37498. */
  37499. buttonsYaw: number[];
  37500. /**
  37501. * Assign buttons for Pitch control.
  37502. */
  37503. buttonsPitch: number[];
  37504. /**
  37505. * Assign buttons for Roll control.
  37506. */
  37507. buttonsRoll: number[];
  37508. /**
  37509. * Detect if any button is being pressed while mouse is moved.
  37510. * -1 = Mouse locked.
  37511. * 0 = Left button.
  37512. * 1 = Middle Button.
  37513. * 2 = Right Button.
  37514. */
  37515. activeButton: number;
  37516. /**
  37517. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37518. * Higher values reduce its sensitivity.
  37519. */
  37520. angularSensibility: number;
  37521. private _mousemoveCallback;
  37522. private _observer;
  37523. private _rollObserver;
  37524. private previousPosition;
  37525. private noPreventDefault;
  37526. private element;
  37527. /**
  37528. * Listen to mouse events to control the camera.
  37529. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37531. */
  37532. constructor(touchEnabled?: boolean);
  37533. /**
  37534. * Attach the mouse control to the HTML DOM element.
  37535. * @param element Defines the element that listens to the input events.
  37536. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37537. */
  37538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37539. /**
  37540. * Detach the current controls from the specified dom element.
  37541. * @param element Defines the element to stop listening the inputs from
  37542. */
  37543. detachControl(element: Nullable<HTMLElement>): void;
  37544. /**
  37545. * Gets the class name of the current input.
  37546. * @returns the class name.
  37547. */
  37548. getClassName(): string;
  37549. /**
  37550. * Get the friendly name associated with the input class.
  37551. * @returns the input's friendly name.
  37552. */
  37553. getSimpleName(): string;
  37554. private _pointerInput;
  37555. private _onMouseMove;
  37556. /**
  37557. * Rotate camera by mouse offset.
  37558. */
  37559. private rotateCamera;
  37560. }
  37561. }
  37562. declare module BABYLON {
  37563. /**
  37564. * Default Inputs manager for the FlyCamera.
  37565. * It groups all the default supported inputs for ease of use.
  37566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37567. */
  37568. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37569. /**
  37570. * Instantiates a new FlyCameraInputsManager.
  37571. * @param camera Defines the camera the inputs belong to.
  37572. */
  37573. constructor(camera: FlyCamera);
  37574. /**
  37575. * Add keyboard input support to the input manager.
  37576. * @returns the new FlyCameraKeyboardMoveInput().
  37577. */
  37578. addKeyboard(): FlyCameraInputsManager;
  37579. /**
  37580. * Add mouse input support to the input manager.
  37581. * @param touchEnabled Enable touch screen support.
  37582. * @returns the new FlyCameraMouseInput().
  37583. */
  37584. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37585. }
  37586. }
  37587. declare module BABYLON {
  37588. /**
  37589. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37590. * such as in a 3D Space Shooter or a Flight Simulator.
  37591. */
  37592. export class FlyCamera extends TargetCamera {
  37593. /**
  37594. * Define the collision ellipsoid of the camera.
  37595. * This is helpful for simulating a camera body, like a player's body.
  37596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37597. */
  37598. ellipsoid: Vector3;
  37599. /**
  37600. * Define an offset for the position of the ellipsoid around the camera.
  37601. * This can be helpful if the camera is attached away from the player's body center,
  37602. * such as at its head.
  37603. */
  37604. ellipsoidOffset: Vector3;
  37605. /**
  37606. * Enable or disable collisions of the camera with the rest of the scene objects.
  37607. */
  37608. checkCollisions: boolean;
  37609. /**
  37610. * Enable or disable gravity on the camera.
  37611. */
  37612. applyGravity: boolean;
  37613. /**
  37614. * Define the current direction the camera is moving to.
  37615. */
  37616. cameraDirection: Vector3;
  37617. /**
  37618. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37619. * This overrides and empties cameraRotation.
  37620. */
  37621. rotationQuaternion: Quaternion;
  37622. /**
  37623. * Track Roll to maintain the wanted Rolling when looking around.
  37624. */
  37625. _trackRoll: number;
  37626. /**
  37627. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37628. */
  37629. rollCorrect: number;
  37630. /**
  37631. * Mimic a banked turn, Rolling the camera when Yawing.
  37632. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37633. */
  37634. bankedTurn: boolean;
  37635. /**
  37636. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37637. */
  37638. bankedTurnLimit: number;
  37639. /**
  37640. * Value of 0 disables the banked Roll.
  37641. * Value of 1 is equal to the Yaw angle in radians.
  37642. */
  37643. bankedTurnMultiplier: number;
  37644. /**
  37645. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37646. */
  37647. inputs: FlyCameraInputsManager;
  37648. /**
  37649. * Gets the input sensibility for mouse input.
  37650. * Higher values reduce sensitivity.
  37651. */
  37652. /**
  37653. * Sets the input sensibility for a mouse input.
  37654. * Higher values reduce sensitivity.
  37655. */
  37656. angularSensibility: number;
  37657. /**
  37658. * Get the keys for camera movement forward.
  37659. */
  37660. /**
  37661. * Set the keys for camera movement forward.
  37662. */
  37663. keysForward: number[];
  37664. /**
  37665. * Get the keys for camera movement backward.
  37666. */
  37667. keysBackward: number[];
  37668. /**
  37669. * Get the keys for camera movement up.
  37670. */
  37671. /**
  37672. * Set the keys for camera movement up.
  37673. */
  37674. keysUp: number[];
  37675. /**
  37676. * Get the keys for camera movement down.
  37677. */
  37678. /**
  37679. * Set the keys for camera movement down.
  37680. */
  37681. keysDown: number[];
  37682. /**
  37683. * Get the keys for camera movement left.
  37684. */
  37685. /**
  37686. * Set the keys for camera movement left.
  37687. */
  37688. keysLeft: number[];
  37689. /**
  37690. * Set the keys for camera movement right.
  37691. */
  37692. /**
  37693. * Set the keys for camera movement right.
  37694. */
  37695. keysRight: number[];
  37696. /**
  37697. * Event raised when the camera collides with a mesh in the scene.
  37698. */
  37699. onCollide: (collidedMesh: AbstractMesh) => void;
  37700. private _collider;
  37701. private _needMoveForGravity;
  37702. private _oldPosition;
  37703. private _diffPosition;
  37704. private _newPosition;
  37705. /** @hidden */
  37706. _localDirection: Vector3;
  37707. /** @hidden */
  37708. _transformedDirection: Vector3;
  37709. /**
  37710. * Instantiates a FlyCamera.
  37711. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37712. * such as in a 3D Space Shooter or a Flight Simulator.
  37713. * @param name Define the name of the camera in the scene.
  37714. * @param position Define the starting position of the camera in the scene.
  37715. * @param scene Define the scene the camera belongs to.
  37716. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37717. */
  37718. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37719. /**
  37720. * Attach a control to the HTML DOM element.
  37721. * @param element Defines the element that listens to the input events.
  37722. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37723. */
  37724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37725. /**
  37726. * Detach a control from the HTML DOM element.
  37727. * The camera will stop reacting to that input.
  37728. * @param element Defines the element that listens to the input events.
  37729. */
  37730. detachControl(element: HTMLElement): void;
  37731. private _collisionMask;
  37732. /**
  37733. * Get the mask that the camera ignores in collision events.
  37734. */
  37735. /**
  37736. * Set the mask that the camera ignores in collision events.
  37737. */
  37738. collisionMask: number;
  37739. /** @hidden */
  37740. _collideWithWorld(displacement: Vector3): void;
  37741. /** @hidden */
  37742. private _onCollisionPositionChange;
  37743. /** @hidden */
  37744. _checkInputs(): void;
  37745. /** @hidden */
  37746. _decideIfNeedsToMove(): boolean;
  37747. /** @hidden */
  37748. _updatePosition(): void;
  37749. /**
  37750. * Restore the Roll to its target value at the rate specified.
  37751. * @param rate - Higher means slower restoring.
  37752. * @hidden
  37753. */
  37754. restoreRoll(rate: number): void;
  37755. /**
  37756. * Destroy the camera and release the current resources held by it.
  37757. */
  37758. dispose(): void;
  37759. /**
  37760. * Get the current object class name.
  37761. * @returns the class name.
  37762. */
  37763. getClassName(): string;
  37764. }
  37765. }
  37766. declare module BABYLON {
  37767. /**
  37768. * Listen to keyboard events to control the camera.
  37769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37770. */
  37771. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37772. /**
  37773. * Defines the camera the input is attached to.
  37774. */
  37775. camera: FlyCamera;
  37776. /**
  37777. * The list of keyboard keys used to control the forward move of the camera.
  37778. */
  37779. keysForward: number[];
  37780. /**
  37781. * The list of keyboard keys used to control the backward move of the camera.
  37782. */
  37783. keysBackward: number[];
  37784. /**
  37785. * The list of keyboard keys used to control the forward move of the camera.
  37786. */
  37787. keysUp: number[];
  37788. /**
  37789. * The list of keyboard keys used to control the backward move of the camera.
  37790. */
  37791. keysDown: number[];
  37792. /**
  37793. * The list of keyboard keys used to control the right strafe move of the camera.
  37794. */
  37795. keysRight: number[];
  37796. /**
  37797. * The list of keyboard keys used to control the left strafe move of the camera.
  37798. */
  37799. keysLeft: number[];
  37800. private _keys;
  37801. private _onCanvasBlurObserver;
  37802. private _onKeyboardObserver;
  37803. private _engine;
  37804. private _scene;
  37805. /**
  37806. * Attach the input controls to a specific dom element to get the input from.
  37807. * @param element Defines the element the controls should be listened from
  37808. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37809. */
  37810. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37811. /**
  37812. * Detach the current controls from the specified dom element.
  37813. * @param element Defines the element to stop listening the inputs from
  37814. */
  37815. detachControl(element: Nullable<HTMLElement>): void;
  37816. /**
  37817. * Gets the class name of the current intput.
  37818. * @returns the class name
  37819. */
  37820. getClassName(): string;
  37821. /** @hidden */
  37822. _onLostFocus(e: FocusEvent): void;
  37823. /**
  37824. * Get the friendly name associated with the input class.
  37825. * @returns the input friendly name
  37826. */
  37827. getSimpleName(): string;
  37828. /**
  37829. * Update the current camera state depending on the inputs that have been used this frame.
  37830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37831. */
  37832. checkInputs(): void;
  37833. }
  37834. }
  37835. declare module BABYLON {
  37836. /**
  37837. * Manage the mouse wheel inputs to control a follow camera.
  37838. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37839. */
  37840. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37841. /**
  37842. * Defines the camera the input is attached to.
  37843. */
  37844. camera: FollowCamera;
  37845. /**
  37846. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37847. */
  37848. axisControlRadius: boolean;
  37849. /**
  37850. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37851. */
  37852. axisControlHeight: boolean;
  37853. /**
  37854. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37855. */
  37856. axisControlRotation: boolean;
  37857. /**
  37858. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37859. * relation to mouseWheel events.
  37860. */
  37861. wheelPrecision: number;
  37862. /**
  37863. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37864. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37865. */
  37866. wheelDeltaPercentage: number;
  37867. private _wheel;
  37868. private _observer;
  37869. /**
  37870. * Attach the input controls to a specific dom element to get the input from.
  37871. * @param element Defines the element the controls should be listened from
  37872. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37873. */
  37874. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37875. /**
  37876. * Detach the current controls from the specified dom element.
  37877. * @param element Defines the element to stop listening the inputs from
  37878. */
  37879. detachControl(element: Nullable<HTMLElement>): void;
  37880. /**
  37881. * Gets the class name of the current intput.
  37882. * @returns the class name
  37883. */
  37884. getClassName(): string;
  37885. /**
  37886. * Get the friendly name associated with the input class.
  37887. * @returns the input friendly name
  37888. */
  37889. getSimpleName(): string;
  37890. }
  37891. }
  37892. declare module BABYLON {
  37893. /**
  37894. * Manage the pointers inputs to control an follow camera.
  37895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37896. */
  37897. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37898. /**
  37899. * Defines the camera the input is attached to.
  37900. */
  37901. camera: FollowCamera;
  37902. /**
  37903. * Gets the class name of the current input.
  37904. * @returns the class name
  37905. */
  37906. getClassName(): string;
  37907. /**
  37908. * Defines the pointer angular sensibility along the X axis or how fast is
  37909. * the camera rotating.
  37910. * A negative number will reverse the axis direction.
  37911. */
  37912. angularSensibilityX: number;
  37913. /**
  37914. * Defines the pointer angular sensibility along the Y axis or how fast is
  37915. * the camera rotating.
  37916. * A negative number will reverse the axis direction.
  37917. */
  37918. angularSensibilityY: number;
  37919. /**
  37920. * Defines the pointer pinch precision or how fast is the camera zooming.
  37921. * A negative number will reverse the axis direction.
  37922. */
  37923. pinchPrecision: number;
  37924. /**
  37925. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37926. * from 0.
  37927. * It defines the percentage of current camera.radius to use as delta when
  37928. * pinch zoom is used.
  37929. */
  37930. pinchDeltaPercentage: number;
  37931. /**
  37932. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37933. */
  37934. axisXControlRadius: boolean;
  37935. /**
  37936. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37937. */
  37938. axisXControlHeight: boolean;
  37939. /**
  37940. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37941. */
  37942. axisXControlRotation: boolean;
  37943. /**
  37944. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37945. */
  37946. axisYControlRadius: boolean;
  37947. /**
  37948. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37949. */
  37950. axisYControlHeight: boolean;
  37951. /**
  37952. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37953. */
  37954. axisYControlRotation: boolean;
  37955. /**
  37956. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37957. */
  37958. axisPinchControlRadius: boolean;
  37959. /**
  37960. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37961. */
  37962. axisPinchControlHeight: boolean;
  37963. /**
  37964. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37965. */
  37966. axisPinchControlRotation: boolean;
  37967. /**
  37968. * Log error messages if basic misconfiguration has occurred.
  37969. */
  37970. warningEnable: boolean;
  37971. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37972. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37973. private _warningCounter;
  37974. private _warning;
  37975. }
  37976. }
  37977. declare module BABYLON {
  37978. /**
  37979. * Default Inputs manager for the FollowCamera.
  37980. * It groups all the default supported inputs for ease of use.
  37981. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37982. */
  37983. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37984. /**
  37985. * Instantiates a new FollowCameraInputsManager.
  37986. * @param camera Defines the camera the inputs belong to
  37987. */
  37988. constructor(camera: FollowCamera);
  37989. /**
  37990. * Add keyboard input support to the input manager.
  37991. * @returns the current input manager
  37992. */
  37993. addKeyboard(): FollowCameraInputsManager;
  37994. /**
  37995. * Add mouse wheel input support to the input manager.
  37996. * @returns the current input manager
  37997. */
  37998. addMouseWheel(): FollowCameraInputsManager;
  37999. /**
  38000. * Add pointers input support to the input manager.
  38001. * @returns the current input manager
  38002. */
  38003. addPointers(): FollowCameraInputsManager;
  38004. /**
  38005. * Add orientation input support to the input manager.
  38006. * @returns the current input manager
  38007. */
  38008. addVRDeviceOrientation(): FollowCameraInputsManager;
  38009. }
  38010. }
  38011. declare module BABYLON {
  38012. /**
  38013. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38014. * an arc rotate version arcFollowCamera are available.
  38015. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38016. */
  38017. export class FollowCamera extends TargetCamera {
  38018. /**
  38019. * Distance the follow camera should follow an object at
  38020. */
  38021. radius: number;
  38022. /**
  38023. * Minimum allowed distance of the camera to the axis of rotation
  38024. * (The camera can not get closer).
  38025. * This can help limiting how the Camera is able to move in the scene.
  38026. */
  38027. lowerRadiusLimit: Nullable<number>;
  38028. /**
  38029. * Maximum allowed distance of the camera to the axis of rotation
  38030. * (The camera can not get further).
  38031. * This can help limiting how the Camera is able to move in the scene.
  38032. */
  38033. upperRadiusLimit: Nullable<number>;
  38034. /**
  38035. * Define a rotation offset between the camera and the object it follows
  38036. */
  38037. rotationOffset: number;
  38038. /**
  38039. * Minimum allowed angle to camera position relative to target object.
  38040. * This can help limiting how the Camera is able to move in the scene.
  38041. */
  38042. lowerRotationOffsetLimit: Nullable<number>;
  38043. /**
  38044. * Maximum allowed angle to camera position relative to target object.
  38045. * This can help limiting how the Camera is able to move in the scene.
  38046. */
  38047. upperRotationOffsetLimit: Nullable<number>;
  38048. /**
  38049. * Define a height offset between the camera and the object it follows.
  38050. * It can help following an object from the top (like a car chaing a plane)
  38051. */
  38052. heightOffset: number;
  38053. /**
  38054. * Minimum allowed height of camera position relative to target object.
  38055. * This can help limiting how the Camera is able to move in the scene.
  38056. */
  38057. lowerHeightOffsetLimit: Nullable<number>;
  38058. /**
  38059. * Maximum allowed height of camera position relative to target object.
  38060. * This can help limiting how the Camera is able to move in the scene.
  38061. */
  38062. upperHeightOffsetLimit: Nullable<number>;
  38063. /**
  38064. * Define how fast the camera can accelerate to follow it s target.
  38065. */
  38066. cameraAcceleration: number;
  38067. /**
  38068. * Define the speed limit of the camera following an object.
  38069. */
  38070. maxCameraSpeed: number;
  38071. /**
  38072. * Define the target of the camera.
  38073. */
  38074. lockedTarget: Nullable<AbstractMesh>;
  38075. /**
  38076. * Defines the input associated with the camera.
  38077. */
  38078. inputs: FollowCameraInputsManager;
  38079. /**
  38080. * Instantiates the follow camera.
  38081. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38082. * @param name Define the name of the camera in the scene
  38083. * @param position Define the position of the camera
  38084. * @param scene Define the scene the camera belong to
  38085. * @param lockedTarget Define the target of the camera
  38086. */
  38087. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38088. private _follow;
  38089. /**
  38090. * Attached controls to the current camera.
  38091. * @param element Defines the element the controls should be listened from
  38092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38093. */
  38094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38095. /**
  38096. * Detach the current controls from the camera.
  38097. * The camera will stop reacting to inputs.
  38098. * @param element Defines the element to stop listening the inputs from
  38099. */
  38100. detachControl(element: HTMLElement): void;
  38101. /** @hidden */
  38102. _checkInputs(): void;
  38103. private _checkLimits;
  38104. /**
  38105. * Gets the camera class name.
  38106. * @returns the class name
  38107. */
  38108. getClassName(): string;
  38109. }
  38110. /**
  38111. * Arc Rotate version of the follow camera.
  38112. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38113. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38114. */
  38115. export class ArcFollowCamera extends TargetCamera {
  38116. /** The longitudinal angle of the camera */
  38117. alpha: number;
  38118. /** The latitudinal angle of the camera */
  38119. beta: number;
  38120. /** The radius of the camera from its target */
  38121. radius: number;
  38122. /** Define the camera target (the messh it should follow) */
  38123. target: Nullable<AbstractMesh>;
  38124. private _cartesianCoordinates;
  38125. /**
  38126. * Instantiates a new ArcFollowCamera
  38127. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38128. * @param name Define the name of the camera
  38129. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38130. * @param beta Define the rotation angle of the camera around the elevation axis
  38131. * @param radius Define the radius of the camera from its target point
  38132. * @param target Define the target of the camera
  38133. * @param scene Define the scene the camera belongs to
  38134. */
  38135. constructor(name: string,
  38136. /** The longitudinal angle of the camera */
  38137. alpha: number,
  38138. /** The latitudinal angle of the camera */
  38139. beta: number,
  38140. /** The radius of the camera from its target */
  38141. radius: number,
  38142. /** Define the camera target (the messh it should follow) */
  38143. target: Nullable<AbstractMesh>, scene: Scene);
  38144. private _follow;
  38145. /** @hidden */
  38146. _checkInputs(): void;
  38147. /**
  38148. * Returns the class name of the object.
  38149. * It is mostly used internally for serialization purposes.
  38150. */
  38151. getClassName(): string;
  38152. }
  38153. }
  38154. declare module BABYLON {
  38155. /**
  38156. * Manage the keyboard inputs to control the movement of a follow camera.
  38157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38158. */
  38159. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38160. /**
  38161. * Defines the camera the input is attached to.
  38162. */
  38163. camera: FollowCamera;
  38164. /**
  38165. * Defines the list of key codes associated with the up action (increase heightOffset)
  38166. */
  38167. keysHeightOffsetIncr: number[];
  38168. /**
  38169. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38170. */
  38171. keysHeightOffsetDecr: number[];
  38172. /**
  38173. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38174. */
  38175. keysHeightOffsetModifierAlt: boolean;
  38176. /**
  38177. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38178. */
  38179. keysHeightOffsetModifierCtrl: boolean;
  38180. /**
  38181. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38182. */
  38183. keysHeightOffsetModifierShift: boolean;
  38184. /**
  38185. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38186. */
  38187. keysRotationOffsetIncr: number[];
  38188. /**
  38189. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38190. */
  38191. keysRotationOffsetDecr: number[];
  38192. /**
  38193. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38194. */
  38195. keysRotationOffsetModifierAlt: boolean;
  38196. /**
  38197. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38198. */
  38199. keysRotationOffsetModifierCtrl: boolean;
  38200. /**
  38201. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38202. */
  38203. keysRotationOffsetModifierShift: boolean;
  38204. /**
  38205. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38206. */
  38207. keysRadiusIncr: number[];
  38208. /**
  38209. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38210. */
  38211. keysRadiusDecr: number[];
  38212. /**
  38213. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38214. */
  38215. keysRadiusModifierAlt: boolean;
  38216. /**
  38217. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38218. */
  38219. keysRadiusModifierCtrl: boolean;
  38220. /**
  38221. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38222. */
  38223. keysRadiusModifierShift: boolean;
  38224. /**
  38225. * Defines the rate of change of heightOffset.
  38226. */
  38227. heightSensibility: number;
  38228. /**
  38229. * Defines the rate of change of rotationOffset.
  38230. */
  38231. rotationSensibility: number;
  38232. /**
  38233. * Defines the rate of change of radius.
  38234. */
  38235. radiusSensibility: number;
  38236. private _keys;
  38237. private _ctrlPressed;
  38238. private _altPressed;
  38239. private _shiftPressed;
  38240. private _onCanvasBlurObserver;
  38241. private _onKeyboardObserver;
  38242. private _engine;
  38243. private _scene;
  38244. /**
  38245. * Attach the input controls to a specific dom element to get the input from.
  38246. * @param element Defines the element the controls should be listened from
  38247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38248. */
  38249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38250. /**
  38251. * Detach the current controls from the specified dom element.
  38252. * @param element Defines the element to stop listening the inputs from
  38253. */
  38254. detachControl(element: Nullable<HTMLElement>): void;
  38255. /**
  38256. * Update the current camera state depending on the inputs that have been used this frame.
  38257. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38258. */
  38259. checkInputs(): void;
  38260. /**
  38261. * Gets the class name of the current input.
  38262. * @returns the class name
  38263. */
  38264. getClassName(): string;
  38265. /**
  38266. * Get the friendly name associated with the input class.
  38267. * @returns the input friendly name
  38268. */
  38269. getSimpleName(): string;
  38270. /**
  38271. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38272. * allow modification of the heightOffset value.
  38273. */
  38274. private _modifierHeightOffset;
  38275. /**
  38276. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38277. * allow modification of the rotationOffset value.
  38278. */
  38279. private _modifierRotationOffset;
  38280. /**
  38281. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38282. * allow modification of the radius value.
  38283. */
  38284. private _modifierRadius;
  38285. }
  38286. }
  38287. declare module BABYLON {
  38288. interface FreeCameraInputsManager {
  38289. /**
  38290. * @hidden
  38291. */
  38292. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38293. /**
  38294. * Add orientation input support to the input manager.
  38295. * @returns the current input manager
  38296. */
  38297. addDeviceOrientation(): FreeCameraInputsManager;
  38298. }
  38299. /**
  38300. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38301. * Screen rotation is taken into account.
  38302. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38303. */
  38304. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38305. private _camera;
  38306. private _screenOrientationAngle;
  38307. private _constantTranform;
  38308. private _screenQuaternion;
  38309. private _alpha;
  38310. private _beta;
  38311. private _gamma;
  38312. /**
  38313. * Can be used to detect if a device orientation sensor is availible on a device
  38314. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38315. * @returns a promise that will resolve on orientation change
  38316. */
  38317. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38318. /**
  38319. * @hidden
  38320. */
  38321. _onDeviceOrientationChangedObservable: Observable<void>;
  38322. /**
  38323. * Instantiates a new input
  38324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38325. */
  38326. constructor();
  38327. /**
  38328. * Define the camera controlled by the input.
  38329. */
  38330. camera: FreeCamera;
  38331. /**
  38332. * Attach the input controls to a specific dom element to get the input from.
  38333. * @param element Defines the element the controls should be listened from
  38334. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38335. */
  38336. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38337. private _orientationChanged;
  38338. private _deviceOrientation;
  38339. /**
  38340. * Detach the current controls from the specified dom element.
  38341. * @param element Defines the element to stop listening the inputs from
  38342. */
  38343. detachControl(element: Nullable<HTMLElement>): void;
  38344. /**
  38345. * Update the current camera state depending on the inputs that have been used this frame.
  38346. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38347. */
  38348. checkInputs(): void;
  38349. /**
  38350. * Gets the class name of the current intput.
  38351. * @returns the class name
  38352. */
  38353. getClassName(): string;
  38354. /**
  38355. * Get the friendly name associated with the input class.
  38356. * @returns the input friendly name
  38357. */
  38358. getSimpleName(): string;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * Manage the gamepad inputs to control a free camera.
  38364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38365. */
  38366. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38367. /**
  38368. * Define the camera the input is attached to.
  38369. */
  38370. camera: FreeCamera;
  38371. /**
  38372. * Define the Gamepad controlling the input
  38373. */
  38374. gamepad: Nullable<Gamepad>;
  38375. /**
  38376. * Defines the gamepad rotation sensiblity.
  38377. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38378. */
  38379. gamepadAngularSensibility: number;
  38380. /**
  38381. * Defines the gamepad move sensiblity.
  38382. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38383. */
  38384. gamepadMoveSensibility: number;
  38385. private _onGamepadConnectedObserver;
  38386. private _onGamepadDisconnectedObserver;
  38387. private _cameraTransform;
  38388. private _deltaTransform;
  38389. private _vector3;
  38390. private _vector2;
  38391. /**
  38392. * Attach the input controls to a specific dom element to get the input from.
  38393. * @param element Defines the element the controls should be listened from
  38394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38395. */
  38396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38397. /**
  38398. * Detach the current controls from the specified dom element.
  38399. * @param element Defines the element to stop listening the inputs from
  38400. */
  38401. detachControl(element: Nullable<HTMLElement>): void;
  38402. /**
  38403. * Update the current camera state depending on the inputs that have been used this frame.
  38404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38405. */
  38406. checkInputs(): void;
  38407. /**
  38408. * Gets the class name of the current intput.
  38409. * @returns the class name
  38410. */
  38411. getClassName(): string;
  38412. /**
  38413. * Get the friendly name associated with the input class.
  38414. * @returns the input friendly name
  38415. */
  38416. getSimpleName(): string;
  38417. }
  38418. }
  38419. declare module BABYLON {
  38420. /**
  38421. * Defines the potential axis of a Joystick
  38422. */
  38423. export enum JoystickAxis {
  38424. /** X axis */
  38425. X = 0,
  38426. /** Y axis */
  38427. Y = 1,
  38428. /** Z axis */
  38429. Z = 2
  38430. }
  38431. /**
  38432. * Class used to define virtual joystick (used in touch mode)
  38433. */
  38434. export class VirtualJoystick {
  38435. /**
  38436. * Gets or sets a boolean indicating that left and right values must be inverted
  38437. */
  38438. reverseLeftRight: boolean;
  38439. /**
  38440. * Gets or sets a boolean indicating that up and down values must be inverted
  38441. */
  38442. reverseUpDown: boolean;
  38443. /**
  38444. * Gets the offset value for the position (ie. the change of the position value)
  38445. */
  38446. deltaPosition: Vector3;
  38447. /**
  38448. * Gets a boolean indicating if the virtual joystick was pressed
  38449. */
  38450. pressed: boolean;
  38451. /**
  38452. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38453. */
  38454. static Canvas: Nullable<HTMLCanvasElement>;
  38455. private static _globalJoystickIndex;
  38456. private static vjCanvasContext;
  38457. private static vjCanvasWidth;
  38458. private static vjCanvasHeight;
  38459. private static halfWidth;
  38460. private _action;
  38461. private _axisTargetedByLeftAndRight;
  38462. private _axisTargetedByUpAndDown;
  38463. private _joystickSensibility;
  38464. private _inversedSensibility;
  38465. private _joystickPointerID;
  38466. private _joystickColor;
  38467. private _joystickPointerPos;
  38468. private _joystickPreviousPointerPos;
  38469. private _joystickPointerStartPos;
  38470. private _deltaJoystickVector;
  38471. private _leftJoystick;
  38472. private _touches;
  38473. private _onPointerDownHandlerRef;
  38474. private _onPointerMoveHandlerRef;
  38475. private _onPointerUpHandlerRef;
  38476. private _onResize;
  38477. /**
  38478. * Creates a new virtual joystick
  38479. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38480. */
  38481. constructor(leftJoystick?: boolean);
  38482. /**
  38483. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38484. * @param newJoystickSensibility defines the new sensibility
  38485. */
  38486. setJoystickSensibility(newJoystickSensibility: number): void;
  38487. private _onPointerDown;
  38488. private _onPointerMove;
  38489. private _onPointerUp;
  38490. /**
  38491. * Change the color of the virtual joystick
  38492. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38493. */
  38494. setJoystickColor(newColor: string): void;
  38495. /**
  38496. * Defines a callback to call when the joystick is touched
  38497. * @param action defines the callback
  38498. */
  38499. setActionOnTouch(action: () => any): void;
  38500. /**
  38501. * Defines which axis you'd like to control for left & right
  38502. * @param axis defines the axis to use
  38503. */
  38504. setAxisForLeftRight(axis: JoystickAxis): void;
  38505. /**
  38506. * Defines which axis you'd like to control for up & down
  38507. * @param axis defines the axis to use
  38508. */
  38509. setAxisForUpDown(axis: JoystickAxis): void;
  38510. private _drawVirtualJoystick;
  38511. /**
  38512. * Release internal HTML canvas
  38513. */
  38514. releaseCanvas(): void;
  38515. }
  38516. }
  38517. declare module BABYLON {
  38518. interface FreeCameraInputsManager {
  38519. /**
  38520. * Add virtual joystick input support to the input manager.
  38521. * @returns the current input manager
  38522. */
  38523. addVirtualJoystick(): FreeCameraInputsManager;
  38524. }
  38525. /**
  38526. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38528. */
  38529. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38530. /**
  38531. * Defines the camera the input is attached to.
  38532. */
  38533. camera: FreeCamera;
  38534. private _leftjoystick;
  38535. private _rightjoystick;
  38536. /**
  38537. * Gets the left stick of the virtual joystick.
  38538. * @returns The virtual Joystick
  38539. */
  38540. getLeftJoystick(): VirtualJoystick;
  38541. /**
  38542. * Gets the right stick of the virtual joystick.
  38543. * @returns The virtual Joystick
  38544. */
  38545. getRightJoystick(): VirtualJoystick;
  38546. /**
  38547. * Update the current camera state depending on the inputs that have been used this frame.
  38548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38549. */
  38550. checkInputs(): void;
  38551. /**
  38552. * Attach the input controls to a specific dom element to get the input from.
  38553. * @param element Defines the element the controls should be listened from
  38554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38555. */
  38556. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38557. /**
  38558. * Detach the current controls from the specified dom element.
  38559. * @param element Defines the element to stop listening the inputs from
  38560. */
  38561. detachControl(element: Nullable<HTMLElement>): void;
  38562. /**
  38563. * Gets the class name of the current intput.
  38564. * @returns the class name
  38565. */
  38566. getClassName(): string;
  38567. /**
  38568. * Get the friendly name associated with the input class.
  38569. * @returns the input friendly name
  38570. */
  38571. getSimpleName(): string;
  38572. }
  38573. }
  38574. declare module BABYLON {
  38575. /**
  38576. * This represents a FPS type of camera controlled by touch.
  38577. * This is like a universal camera minus the Gamepad controls.
  38578. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38579. */
  38580. export class TouchCamera extends FreeCamera {
  38581. /**
  38582. * Defines the touch sensibility for rotation.
  38583. * The higher the faster.
  38584. */
  38585. touchAngularSensibility: number;
  38586. /**
  38587. * Defines the touch sensibility for move.
  38588. * The higher the faster.
  38589. */
  38590. touchMoveSensibility: number;
  38591. /**
  38592. * Instantiates a new touch camera.
  38593. * This represents a FPS type of camera controlled by touch.
  38594. * This is like a universal camera minus the Gamepad controls.
  38595. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38596. * @param name Define the name of the camera in the scene
  38597. * @param position Define the start position of the camera in the scene
  38598. * @param scene Define the scene the camera belongs to
  38599. */
  38600. constructor(name: string, position: Vector3, scene: Scene);
  38601. /**
  38602. * Gets the current object class name.
  38603. * @return the class name
  38604. */
  38605. getClassName(): string;
  38606. /** @hidden */
  38607. _setupInputs(): void;
  38608. }
  38609. }
  38610. declare module BABYLON {
  38611. /**
  38612. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38613. * being tilted forward or back and left or right.
  38614. */
  38615. export class DeviceOrientationCamera extends FreeCamera {
  38616. private _initialQuaternion;
  38617. private _quaternionCache;
  38618. private _tmpDragQuaternion;
  38619. private _disablePointerInputWhenUsingDeviceOrientation;
  38620. /**
  38621. * Creates a new device orientation camera
  38622. * @param name The name of the camera
  38623. * @param position The start position camera
  38624. * @param scene The scene the camera belongs to
  38625. */
  38626. constructor(name: string, position: Vector3, scene: Scene);
  38627. /**
  38628. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  38629. */
  38630. disablePointerInputWhenUsingDeviceOrientation: boolean;
  38631. private _dragFactor;
  38632. /**
  38633. * Enabled turning on the y axis when the orientation sensor is active
  38634. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38635. */
  38636. enableHorizontalDragging(dragFactor?: number): void;
  38637. /**
  38638. * Gets the current instance class name ("DeviceOrientationCamera").
  38639. * This helps avoiding instanceof at run time.
  38640. * @returns the class name
  38641. */
  38642. getClassName(): string;
  38643. /**
  38644. * @hidden
  38645. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38646. */
  38647. _checkInputs(): void;
  38648. /**
  38649. * Reset the camera to its default orientation on the specified axis only.
  38650. * @param axis The axis to reset
  38651. */
  38652. resetToCurrentRotation(axis?: Axis): void;
  38653. }
  38654. }
  38655. declare module BABYLON {
  38656. /**
  38657. * Defines supported buttons for XBox360 compatible gamepads
  38658. */
  38659. export enum Xbox360Button {
  38660. /** A */
  38661. A = 0,
  38662. /** B */
  38663. B = 1,
  38664. /** X */
  38665. X = 2,
  38666. /** Y */
  38667. Y = 3,
  38668. /** Start */
  38669. Start = 4,
  38670. /** Back */
  38671. Back = 5,
  38672. /** Left button */
  38673. LB = 6,
  38674. /** Right button */
  38675. RB = 7,
  38676. /** Left stick */
  38677. LeftStick = 8,
  38678. /** Right stick */
  38679. RightStick = 9
  38680. }
  38681. /** Defines values for XBox360 DPad */
  38682. export enum Xbox360Dpad {
  38683. /** Up */
  38684. Up = 0,
  38685. /** Down */
  38686. Down = 1,
  38687. /** Left */
  38688. Left = 2,
  38689. /** Right */
  38690. Right = 3
  38691. }
  38692. /**
  38693. * Defines a XBox360 gamepad
  38694. */
  38695. export class Xbox360Pad extends Gamepad {
  38696. private _leftTrigger;
  38697. private _rightTrigger;
  38698. private _onlefttriggerchanged;
  38699. private _onrighttriggerchanged;
  38700. private _onbuttondown;
  38701. private _onbuttonup;
  38702. private _ondpaddown;
  38703. private _ondpadup;
  38704. /** Observable raised when a button is pressed */
  38705. onButtonDownObservable: Observable<Xbox360Button>;
  38706. /** Observable raised when a button is released */
  38707. onButtonUpObservable: Observable<Xbox360Button>;
  38708. /** Observable raised when a pad is pressed */
  38709. onPadDownObservable: Observable<Xbox360Dpad>;
  38710. /** Observable raised when a pad is released */
  38711. onPadUpObservable: Observable<Xbox360Dpad>;
  38712. private _buttonA;
  38713. private _buttonB;
  38714. private _buttonX;
  38715. private _buttonY;
  38716. private _buttonBack;
  38717. private _buttonStart;
  38718. private _buttonLB;
  38719. private _buttonRB;
  38720. private _buttonLeftStick;
  38721. private _buttonRightStick;
  38722. private _dPadUp;
  38723. private _dPadDown;
  38724. private _dPadLeft;
  38725. private _dPadRight;
  38726. private _isXboxOnePad;
  38727. /**
  38728. * Creates a new XBox360 gamepad object
  38729. * @param id defines the id of this gamepad
  38730. * @param index defines its index
  38731. * @param gamepad defines the internal HTML gamepad object
  38732. * @param xboxOne defines if it is a XBox One gamepad
  38733. */
  38734. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38735. /**
  38736. * Defines the callback to call when left trigger is pressed
  38737. * @param callback defines the callback to use
  38738. */
  38739. onlefttriggerchanged(callback: (value: number) => void): void;
  38740. /**
  38741. * Defines the callback to call when right trigger is pressed
  38742. * @param callback defines the callback to use
  38743. */
  38744. onrighttriggerchanged(callback: (value: number) => void): void;
  38745. /**
  38746. * Gets the left trigger value
  38747. */
  38748. /**
  38749. * Sets the left trigger value
  38750. */
  38751. leftTrigger: number;
  38752. /**
  38753. * Gets the right trigger value
  38754. */
  38755. /**
  38756. * Sets the right trigger value
  38757. */
  38758. rightTrigger: number;
  38759. /**
  38760. * Defines the callback to call when a button is pressed
  38761. * @param callback defines the callback to use
  38762. */
  38763. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38764. /**
  38765. * Defines the callback to call when a button is released
  38766. * @param callback defines the callback to use
  38767. */
  38768. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38769. /**
  38770. * Defines the callback to call when a pad is pressed
  38771. * @param callback defines the callback to use
  38772. */
  38773. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38774. /**
  38775. * Defines the callback to call when a pad is released
  38776. * @param callback defines the callback to use
  38777. */
  38778. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38779. private _setButtonValue;
  38780. private _setDPadValue;
  38781. /**
  38782. * Gets the value of the `A` button
  38783. */
  38784. /**
  38785. * Sets the value of the `A` button
  38786. */
  38787. buttonA: number;
  38788. /**
  38789. * Gets the value of the `B` button
  38790. */
  38791. /**
  38792. * Sets the value of the `B` button
  38793. */
  38794. buttonB: number;
  38795. /**
  38796. * Gets the value of the `X` button
  38797. */
  38798. /**
  38799. * Sets the value of the `X` button
  38800. */
  38801. buttonX: number;
  38802. /**
  38803. * Gets the value of the `Y` button
  38804. */
  38805. /**
  38806. * Sets the value of the `Y` button
  38807. */
  38808. buttonY: number;
  38809. /**
  38810. * Gets the value of the `Start` button
  38811. */
  38812. /**
  38813. * Sets the value of the `Start` button
  38814. */
  38815. buttonStart: number;
  38816. /**
  38817. * Gets the value of the `Back` button
  38818. */
  38819. /**
  38820. * Sets the value of the `Back` button
  38821. */
  38822. buttonBack: number;
  38823. /**
  38824. * Gets the value of the `Left` button
  38825. */
  38826. /**
  38827. * Sets the value of the `Left` button
  38828. */
  38829. buttonLB: number;
  38830. /**
  38831. * Gets the value of the `Right` button
  38832. */
  38833. /**
  38834. * Sets the value of the `Right` button
  38835. */
  38836. buttonRB: number;
  38837. /**
  38838. * Gets the value of the Left joystick
  38839. */
  38840. /**
  38841. * Sets the value of the Left joystick
  38842. */
  38843. buttonLeftStick: number;
  38844. /**
  38845. * Gets the value of the Right joystick
  38846. */
  38847. /**
  38848. * Sets the value of the Right joystick
  38849. */
  38850. buttonRightStick: number;
  38851. /**
  38852. * Gets the value of D-pad up
  38853. */
  38854. /**
  38855. * Sets the value of D-pad up
  38856. */
  38857. dPadUp: number;
  38858. /**
  38859. * Gets the value of D-pad down
  38860. */
  38861. /**
  38862. * Sets the value of D-pad down
  38863. */
  38864. dPadDown: number;
  38865. /**
  38866. * Gets the value of D-pad left
  38867. */
  38868. /**
  38869. * Sets the value of D-pad left
  38870. */
  38871. dPadLeft: number;
  38872. /**
  38873. * Gets the value of D-pad right
  38874. */
  38875. /**
  38876. * Sets the value of D-pad right
  38877. */
  38878. dPadRight: number;
  38879. /**
  38880. * Force the gamepad to synchronize with device values
  38881. */
  38882. update(): void;
  38883. /**
  38884. * Disposes the gamepad
  38885. */
  38886. dispose(): void;
  38887. }
  38888. }
  38889. declare module BABYLON {
  38890. /**
  38891. * Defines supported buttons for DualShock compatible gamepads
  38892. */
  38893. export enum DualShockButton {
  38894. /** Cross */
  38895. Cross = 0,
  38896. /** Circle */
  38897. Circle = 1,
  38898. /** Square */
  38899. Square = 2,
  38900. /** Triangle */
  38901. Triangle = 3,
  38902. /** Options */
  38903. Options = 4,
  38904. /** Share */
  38905. Share = 5,
  38906. /** L1 */
  38907. L1 = 6,
  38908. /** R1 */
  38909. R1 = 7,
  38910. /** Left stick */
  38911. LeftStick = 8,
  38912. /** Right stick */
  38913. RightStick = 9
  38914. }
  38915. /** Defines values for DualShock DPad */
  38916. export enum DualShockDpad {
  38917. /** Up */
  38918. Up = 0,
  38919. /** Down */
  38920. Down = 1,
  38921. /** Left */
  38922. Left = 2,
  38923. /** Right */
  38924. Right = 3
  38925. }
  38926. /**
  38927. * Defines a DualShock gamepad
  38928. */
  38929. export class DualShockPad extends Gamepad {
  38930. private _leftTrigger;
  38931. private _rightTrigger;
  38932. private _onlefttriggerchanged;
  38933. private _onrighttriggerchanged;
  38934. private _onbuttondown;
  38935. private _onbuttonup;
  38936. private _ondpaddown;
  38937. private _ondpadup;
  38938. /** Observable raised when a button is pressed */
  38939. onButtonDownObservable: Observable<DualShockButton>;
  38940. /** Observable raised when a button is released */
  38941. onButtonUpObservable: Observable<DualShockButton>;
  38942. /** Observable raised when a pad is pressed */
  38943. onPadDownObservable: Observable<DualShockDpad>;
  38944. /** Observable raised when a pad is released */
  38945. onPadUpObservable: Observable<DualShockDpad>;
  38946. private _buttonCross;
  38947. private _buttonCircle;
  38948. private _buttonSquare;
  38949. private _buttonTriangle;
  38950. private _buttonShare;
  38951. private _buttonOptions;
  38952. private _buttonL1;
  38953. private _buttonR1;
  38954. private _buttonLeftStick;
  38955. private _buttonRightStick;
  38956. private _dPadUp;
  38957. private _dPadDown;
  38958. private _dPadLeft;
  38959. private _dPadRight;
  38960. /**
  38961. * Creates a new DualShock gamepad object
  38962. * @param id defines the id of this gamepad
  38963. * @param index defines its index
  38964. * @param gamepad defines the internal HTML gamepad object
  38965. */
  38966. constructor(id: string, index: number, gamepad: any);
  38967. /**
  38968. * Defines the callback to call when left trigger is pressed
  38969. * @param callback defines the callback to use
  38970. */
  38971. onlefttriggerchanged(callback: (value: number) => void): void;
  38972. /**
  38973. * Defines the callback to call when right trigger is pressed
  38974. * @param callback defines the callback to use
  38975. */
  38976. onrighttriggerchanged(callback: (value: number) => void): void;
  38977. /**
  38978. * Gets the left trigger value
  38979. */
  38980. /**
  38981. * Sets the left trigger value
  38982. */
  38983. leftTrigger: number;
  38984. /**
  38985. * Gets the right trigger value
  38986. */
  38987. /**
  38988. * Sets the right trigger value
  38989. */
  38990. rightTrigger: number;
  38991. /**
  38992. * Defines the callback to call when a button is pressed
  38993. * @param callback defines the callback to use
  38994. */
  38995. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38996. /**
  38997. * Defines the callback to call when a button is released
  38998. * @param callback defines the callback to use
  38999. */
  39000. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  39001. /**
  39002. * Defines the callback to call when a pad is pressed
  39003. * @param callback defines the callback to use
  39004. */
  39005. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  39006. /**
  39007. * Defines the callback to call when a pad is released
  39008. * @param callback defines the callback to use
  39009. */
  39010. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  39011. private _setButtonValue;
  39012. private _setDPadValue;
  39013. /**
  39014. * Gets the value of the `Cross` button
  39015. */
  39016. /**
  39017. * Sets the value of the `Cross` button
  39018. */
  39019. buttonCross: number;
  39020. /**
  39021. * Gets the value of the `Circle` button
  39022. */
  39023. /**
  39024. * Sets the value of the `Circle` button
  39025. */
  39026. buttonCircle: number;
  39027. /**
  39028. * Gets the value of the `Square` button
  39029. */
  39030. /**
  39031. * Sets the value of the `Square` button
  39032. */
  39033. buttonSquare: number;
  39034. /**
  39035. * Gets the value of the `Triangle` button
  39036. */
  39037. /**
  39038. * Sets the value of the `Triangle` button
  39039. */
  39040. buttonTriangle: number;
  39041. /**
  39042. * Gets the value of the `Options` button
  39043. */
  39044. /**
  39045. * Sets the value of the `Options` button
  39046. */
  39047. buttonOptions: number;
  39048. /**
  39049. * Gets the value of the `Share` button
  39050. */
  39051. /**
  39052. * Sets the value of the `Share` button
  39053. */
  39054. buttonShare: number;
  39055. /**
  39056. * Gets the value of the `L1` button
  39057. */
  39058. /**
  39059. * Sets the value of the `L1` button
  39060. */
  39061. buttonL1: number;
  39062. /**
  39063. * Gets the value of the `R1` button
  39064. */
  39065. /**
  39066. * Sets the value of the `R1` button
  39067. */
  39068. buttonR1: number;
  39069. /**
  39070. * Gets the value of the Left joystick
  39071. */
  39072. /**
  39073. * Sets the value of the Left joystick
  39074. */
  39075. buttonLeftStick: number;
  39076. /**
  39077. * Gets the value of the Right joystick
  39078. */
  39079. /**
  39080. * Sets the value of the Right joystick
  39081. */
  39082. buttonRightStick: number;
  39083. /**
  39084. * Gets the value of D-pad up
  39085. */
  39086. /**
  39087. * Sets the value of D-pad up
  39088. */
  39089. dPadUp: number;
  39090. /**
  39091. * Gets the value of D-pad down
  39092. */
  39093. /**
  39094. * Sets the value of D-pad down
  39095. */
  39096. dPadDown: number;
  39097. /**
  39098. * Gets the value of D-pad left
  39099. */
  39100. /**
  39101. * Sets the value of D-pad left
  39102. */
  39103. dPadLeft: number;
  39104. /**
  39105. * Gets the value of D-pad right
  39106. */
  39107. /**
  39108. * Sets the value of D-pad right
  39109. */
  39110. dPadRight: number;
  39111. /**
  39112. * Force the gamepad to synchronize with device values
  39113. */
  39114. update(): void;
  39115. /**
  39116. * Disposes the gamepad
  39117. */
  39118. dispose(): void;
  39119. }
  39120. }
  39121. declare module BABYLON {
  39122. /**
  39123. * Manager for handling gamepads
  39124. */
  39125. export class GamepadManager {
  39126. private _scene?;
  39127. private _babylonGamepads;
  39128. private _oneGamepadConnected;
  39129. /** @hidden */
  39130. _isMonitoring: boolean;
  39131. private _gamepadEventSupported;
  39132. private _gamepadSupport;
  39133. /**
  39134. * observable to be triggered when the gamepad controller has been connected
  39135. */
  39136. onGamepadConnectedObservable: Observable<Gamepad>;
  39137. /**
  39138. * observable to be triggered when the gamepad controller has been disconnected
  39139. */
  39140. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39141. private _onGamepadConnectedEvent;
  39142. private _onGamepadDisconnectedEvent;
  39143. /**
  39144. * Initializes the gamepad manager
  39145. * @param _scene BabylonJS scene
  39146. */
  39147. constructor(_scene?: Scene | undefined);
  39148. /**
  39149. * The gamepads in the game pad manager
  39150. */
  39151. readonly gamepads: Gamepad[];
  39152. /**
  39153. * Get the gamepad controllers based on type
  39154. * @param type The type of gamepad controller
  39155. * @returns Nullable gamepad
  39156. */
  39157. getGamepadByType(type?: number): Nullable<Gamepad>;
  39158. /**
  39159. * Disposes the gamepad manager
  39160. */
  39161. dispose(): void;
  39162. private _addNewGamepad;
  39163. private _startMonitoringGamepads;
  39164. private _stopMonitoringGamepads;
  39165. /** @hidden */
  39166. _checkGamepadsStatus(): void;
  39167. private _updateGamepadObjects;
  39168. }
  39169. }
  39170. declare module BABYLON {
  39171. interface Scene {
  39172. /** @hidden */
  39173. _gamepadManager: Nullable<GamepadManager>;
  39174. /**
  39175. * Gets the gamepad manager associated with the scene
  39176. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39177. */
  39178. gamepadManager: GamepadManager;
  39179. }
  39180. /**
  39181. * Interface representing a free camera inputs manager
  39182. */
  39183. interface FreeCameraInputsManager {
  39184. /**
  39185. * Adds gamepad input support to the FreeCameraInputsManager.
  39186. * @returns the FreeCameraInputsManager
  39187. */
  39188. addGamepad(): FreeCameraInputsManager;
  39189. }
  39190. /**
  39191. * Interface representing an arc rotate camera inputs manager
  39192. */
  39193. interface ArcRotateCameraInputsManager {
  39194. /**
  39195. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39196. * @returns the camera inputs manager
  39197. */
  39198. addGamepad(): ArcRotateCameraInputsManager;
  39199. }
  39200. /**
  39201. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39202. */
  39203. export class GamepadSystemSceneComponent implements ISceneComponent {
  39204. /**
  39205. * The component name helpfull to identify the component in the list of scene components.
  39206. */
  39207. readonly name: string;
  39208. /**
  39209. * The scene the component belongs to.
  39210. */
  39211. scene: Scene;
  39212. /**
  39213. * Creates a new instance of the component for the given scene
  39214. * @param scene Defines the scene to register the component in
  39215. */
  39216. constructor(scene: Scene);
  39217. /**
  39218. * Registers the component in a given scene
  39219. */
  39220. register(): void;
  39221. /**
  39222. * Rebuilds the elements related to this component in case of
  39223. * context lost for instance.
  39224. */
  39225. rebuild(): void;
  39226. /**
  39227. * Disposes the component and the associated ressources
  39228. */
  39229. dispose(): void;
  39230. private _beforeCameraUpdate;
  39231. }
  39232. }
  39233. declare module BABYLON {
  39234. /**
  39235. * 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,
  39236. * which still works and will still be found in many Playgrounds.
  39237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39238. */
  39239. export class UniversalCamera extends TouchCamera {
  39240. /**
  39241. * Defines the gamepad rotation sensiblity.
  39242. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39243. */
  39244. gamepadAngularSensibility: number;
  39245. /**
  39246. * Defines the gamepad move sensiblity.
  39247. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39248. */
  39249. gamepadMoveSensibility: number;
  39250. /**
  39251. * 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,
  39252. * which still works and will still be found in many Playgrounds.
  39253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39254. * @param name Define the name of the camera in the scene
  39255. * @param position Define the start position of the camera in the scene
  39256. * @param scene Define the scene the camera belongs to
  39257. */
  39258. constructor(name: string, position: Vector3, scene: Scene);
  39259. /**
  39260. * Gets the current object class name.
  39261. * @return the class name
  39262. */
  39263. getClassName(): string;
  39264. }
  39265. }
  39266. declare module BABYLON {
  39267. /**
  39268. * This represents a FPS type of camera. This is only here for back compat purpose.
  39269. * Please use the UniversalCamera instead as both are identical.
  39270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39271. */
  39272. export class GamepadCamera extends UniversalCamera {
  39273. /**
  39274. * Instantiates a new Gamepad Camera
  39275. * This represents a FPS type of camera. This is only here for back compat purpose.
  39276. * Please use the UniversalCamera instead as both are identical.
  39277. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39278. * @param name Define the name of the camera in the scene
  39279. * @param position Define the start position of the camera in the scene
  39280. * @param scene Define the scene the camera belongs to
  39281. */
  39282. constructor(name: string, position: Vector3, scene: Scene);
  39283. /**
  39284. * Gets the current object class name.
  39285. * @return the class name
  39286. */
  39287. getClassName(): string;
  39288. }
  39289. }
  39290. declare module BABYLON {
  39291. /** @hidden */
  39292. export var passPixelShader: {
  39293. name: string;
  39294. shader: string;
  39295. };
  39296. }
  39297. declare module BABYLON {
  39298. /** @hidden */
  39299. export var passCubePixelShader: {
  39300. name: string;
  39301. shader: string;
  39302. };
  39303. }
  39304. declare module BABYLON {
  39305. /**
  39306. * PassPostProcess which produces an output the same as it's input
  39307. */
  39308. export class PassPostProcess extends PostProcess {
  39309. /**
  39310. * Creates the PassPostProcess
  39311. * @param name The name of the effect.
  39312. * @param options The required width/height ratio to downsize to before computing the render pass.
  39313. * @param camera The camera to apply the render pass to.
  39314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39315. * @param engine The engine which the post process will be applied. (default: current engine)
  39316. * @param reusable If the post process can be reused on the same frame. (default: false)
  39317. * @param textureType The type of texture to be used when performing the post processing.
  39318. * @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)
  39319. */
  39320. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39321. }
  39322. /**
  39323. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39324. */
  39325. export class PassCubePostProcess extends PostProcess {
  39326. private _face;
  39327. /**
  39328. * Gets or sets the cube face to display.
  39329. * * 0 is +X
  39330. * * 1 is -X
  39331. * * 2 is +Y
  39332. * * 3 is -Y
  39333. * * 4 is +Z
  39334. * * 5 is -Z
  39335. */
  39336. face: number;
  39337. /**
  39338. * Creates the PassCubePostProcess
  39339. * @param name The name of the effect.
  39340. * @param options The required width/height ratio to downsize to before computing the render pass.
  39341. * @param camera The camera to apply the render pass to.
  39342. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39343. * @param engine The engine which the post process will be applied. (default: current engine)
  39344. * @param reusable If the post process can be reused on the same frame. (default: false)
  39345. * @param textureType The type of texture to be used when performing the post processing.
  39346. * @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)
  39347. */
  39348. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39349. }
  39350. }
  39351. declare module BABYLON {
  39352. /** @hidden */
  39353. export var anaglyphPixelShader: {
  39354. name: string;
  39355. shader: string;
  39356. };
  39357. }
  39358. declare module BABYLON {
  39359. /**
  39360. * Postprocess used to generate anaglyphic rendering
  39361. */
  39362. export class AnaglyphPostProcess extends PostProcess {
  39363. private _passedProcess;
  39364. /**
  39365. * Creates a new AnaglyphPostProcess
  39366. * @param name defines postprocess name
  39367. * @param options defines creation options or target ratio scale
  39368. * @param rigCameras defines cameras using this postprocess
  39369. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39370. * @param engine defines hosting engine
  39371. * @param reusable defines if the postprocess will be reused multiple times per frame
  39372. */
  39373. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39374. }
  39375. }
  39376. declare module BABYLON {
  39377. /**
  39378. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39379. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39380. */
  39381. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39382. /**
  39383. * Creates a new AnaglyphArcRotateCamera
  39384. * @param name defines camera name
  39385. * @param alpha defines alpha angle (in radians)
  39386. * @param beta defines beta angle (in radians)
  39387. * @param radius defines radius
  39388. * @param target defines camera target
  39389. * @param interaxialDistance defines distance between each color axis
  39390. * @param scene defines the hosting scene
  39391. */
  39392. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39393. /**
  39394. * Gets camera class name
  39395. * @returns AnaglyphArcRotateCamera
  39396. */
  39397. getClassName(): string;
  39398. }
  39399. }
  39400. declare module BABYLON {
  39401. /**
  39402. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39403. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39404. */
  39405. export class AnaglyphFreeCamera extends FreeCamera {
  39406. /**
  39407. * Creates a new AnaglyphFreeCamera
  39408. * @param name defines camera name
  39409. * @param position defines initial position
  39410. * @param interaxialDistance defines distance between each color axis
  39411. * @param scene defines the hosting scene
  39412. */
  39413. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39414. /**
  39415. * Gets camera class name
  39416. * @returns AnaglyphFreeCamera
  39417. */
  39418. getClassName(): string;
  39419. }
  39420. }
  39421. declare module BABYLON {
  39422. /**
  39423. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39424. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39425. */
  39426. export class AnaglyphGamepadCamera extends GamepadCamera {
  39427. /**
  39428. * Creates a new AnaglyphGamepadCamera
  39429. * @param name defines camera name
  39430. * @param position defines initial position
  39431. * @param interaxialDistance defines distance between each color axis
  39432. * @param scene defines the hosting scene
  39433. */
  39434. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39435. /**
  39436. * Gets camera class name
  39437. * @returns AnaglyphGamepadCamera
  39438. */
  39439. getClassName(): string;
  39440. }
  39441. }
  39442. declare module BABYLON {
  39443. /**
  39444. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39445. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39446. */
  39447. export class AnaglyphUniversalCamera extends UniversalCamera {
  39448. /**
  39449. * Creates a new AnaglyphUniversalCamera
  39450. * @param name defines camera name
  39451. * @param position defines initial position
  39452. * @param interaxialDistance defines distance between each color axis
  39453. * @param scene defines the hosting scene
  39454. */
  39455. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39456. /**
  39457. * Gets camera class name
  39458. * @returns AnaglyphUniversalCamera
  39459. */
  39460. getClassName(): string;
  39461. }
  39462. }
  39463. declare module BABYLON {
  39464. /** @hidden */
  39465. export var stereoscopicInterlacePixelShader: {
  39466. name: string;
  39467. shader: string;
  39468. };
  39469. }
  39470. declare module BABYLON {
  39471. /**
  39472. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39473. */
  39474. export class StereoscopicInterlacePostProcess extends PostProcess {
  39475. private _stepSize;
  39476. private _passedProcess;
  39477. /**
  39478. * Initializes a StereoscopicInterlacePostProcess
  39479. * @param name The name of the effect.
  39480. * @param rigCameras The rig cameras to be appled to the post process
  39481. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39483. * @param engine The engine which the post process will be applied. (default: current engine)
  39484. * @param reusable If the post process can be reused on the same frame. (default: false)
  39485. */
  39486. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39487. }
  39488. }
  39489. declare module BABYLON {
  39490. /**
  39491. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39492. * @see http://doc.babylonjs.com/features/cameras
  39493. */
  39494. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39495. /**
  39496. * Creates a new StereoscopicArcRotateCamera
  39497. * @param name defines camera name
  39498. * @param alpha defines alpha angle (in radians)
  39499. * @param beta defines beta angle (in radians)
  39500. * @param radius defines radius
  39501. * @param target defines camera target
  39502. * @param interaxialDistance defines distance between each color axis
  39503. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39504. * @param scene defines the hosting scene
  39505. */
  39506. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39507. /**
  39508. * Gets camera class name
  39509. * @returns StereoscopicArcRotateCamera
  39510. */
  39511. getClassName(): string;
  39512. }
  39513. }
  39514. declare module BABYLON {
  39515. /**
  39516. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39517. * @see http://doc.babylonjs.com/features/cameras
  39518. */
  39519. export class StereoscopicFreeCamera extends FreeCamera {
  39520. /**
  39521. * Creates a new StereoscopicFreeCamera
  39522. * @param name defines camera name
  39523. * @param position defines initial position
  39524. * @param interaxialDistance defines distance between each color axis
  39525. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39526. * @param scene defines the hosting scene
  39527. */
  39528. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39529. /**
  39530. * Gets camera class name
  39531. * @returns StereoscopicFreeCamera
  39532. */
  39533. getClassName(): string;
  39534. }
  39535. }
  39536. declare module BABYLON {
  39537. /**
  39538. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39539. * @see http://doc.babylonjs.com/features/cameras
  39540. */
  39541. export class StereoscopicGamepadCamera extends GamepadCamera {
  39542. /**
  39543. * Creates a new StereoscopicGamepadCamera
  39544. * @param name defines camera name
  39545. * @param position defines initial position
  39546. * @param interaxialDistance defines distance between each color axis
  39547. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39548. * @param scene defines the hosting scene
  39549. */
  39550. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39551. /**
  39552. * Gets camera class name
  39553. * @returns StereoscopicGamepadCamera
  39554. */
  39555. getClassName(): string;
  39556. }
  39557. }
  39558. declare module BABYLON {
  39559. /**
  39560. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39561. * @see http://doc.babylonjs.com/features/cameras
  39562. */
  39563. export class StereoscopicUniversalCamera extends UniversalCamera {
  39564. /**
  39565. * Creates a new StereoscopicUniversalCamera
  39566. * @param name defines camera name
  39567. * @param position defines initial position
  39568. * @param interaxialDistance defines distance between each color axis
  39569. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39570. * @param scene defines the hosting scene
  39571. */
  39572. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39573. /**
  39574. * Gets camera class name
  39575. * @returns StereoscopicUniversalCamera
  39576. */
  39577. getClassName(): string;
  39578. }
  39579. }
  39580. declare module BABYLON {
  39581. /**
  39582. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39583. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39584. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39585. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39586. */
  39587. export class VirtualJoysticksCamera extends FreeCamera {
  39588. /**
  39589. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39590. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39591. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39592. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39593. * @param name Define the name of the camera in the scene
  39594. * @param position Define the start position of the camera in the scene
  39595. * @param scene Define the scene the camera belongs to
  39596. */
  39597. constructor(name: string, position: Vector3, scene: Scene);
  39598. /**
  39599. * Gets the current object class name.
  39600. * @return the class name
  39601. */
  39602. getClassName(): string;
  39603. }
  39604. }
  39605. declare module BABYLON {
  39606. /**
  39607. * This represents all the required metrics to create a VR camera.
  39608. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39609. */
  39610. export class VRCameraMetrics {
  39611. /**
  39612. * Define the horizontal resolution off the screen.
  39613. */
  39614. hResolution: number;
  39615. /**
  39616. * Define the vertical resolution off the screen.
  39617. */
  39618. vResolution: number;
  39619. /**
  39620. * Define the horizontal screen size.
  39621. */
  39622. hScreenSize: number;
  39623. /**
  39624. * Define the vertical screen size.
  39625. */
  39626. vScreenSize: number;
  39627. /**
  39628. * Define the vertical screen center position.
  39629. */
  39630. vScreenCenter: number;
  39631. /**
  39632. * Define the distance of the eyes to the screen.
  39633. */
  39634. eyeToScreenDistance: number;
  39635. /**
  39636. * Define the distance between both lenses
  39637. */
  39638. lensSeparationDistance: number;
  39639. /**
  39640. * Define the distance between both viewer's eyes.
  39641. */
  39642. interpupillaryDistance: number;
  39643. /**
  39644. * Define the distortion factor of the VR postprocess.
  39645. * Please, touch with care.
  39646. */
  39647. distortionK: number[];
  39648. /**
  39649. * Define the chromatic aberration correction factors for the VR post process.
  39650. */
  39651. chromaAbCorrection: number[];
  39652. /**
  39653. * Define the scale factor of the post process.
  39654. * The smaller the better but the slower.
  39655. */
  39656. postProcessScaleFactor: number;
  39657. /**
  39658. * Define an offset for the lens center.
  39659. */
  39660. lensCenterOffset: number;
  39661. /**
  39662. * Define if the current vr camera should compensate the distortion of the lense or not.
  39663. */
  39664. compensateDistortion: boolean;
  39665. /**
  39666. * Defines if multiview should be enabled when rendering (Default: false)
  39667. */
  39668. multiviewEnabled: boolean;
  39669. /**
  39670. * Gets the rendering aspect ratio based on the provided resolutions.
  39671. */
  39672. readonly aspectRatio: number;
  39673. /**
  39674. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39675. */
  39676. readonly aspectRatioFov: number;
  39677. /**
  39678. * @hidden
  39679. */
  39680. readonly leftHMatrix: Matrix;
  39681. /**
  39682. * @hidden
  39683. */
  39684. readonly rightHMatrix: Matrix;
  39685. /**
  39686. * @hidden
  39687. */
  39688. readonly leftPreViewMatrix: Matrix;
  39689. /**
  39690. * @hidden
  39691. */
  39692. readonly rightPreViewMatrix: Matrix;
  39693. /**
  39694. * Get the default VRMetrics based on the most generic setup.
  39695. * @returns the default vr metrics
  39696. */
  39697. static GetDefault(): VRCameraMetrics;
  39698. }
  39699. }
  39700. declare module BABYLON {
  39701. /** @hidden */
  39702. export var vrDistortionCorrectionPixelShader: {
  39703. name: string;
  39704. shader: string;
  39705. };
  39706. }
  39707. declare module BABYLON {
  39708. /**
  39709. * VRDistortionCorrectionPostProcess used for mobile VR
  39710. */
  39711. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39712. private _isRightEye;
  39713. private _distortionFactors;
  39714. private _postProcessScaleFactor;
  39715. private _lensCenterOffset;
  39716. private _scaleIn;
  39717. private _scaleFactor;
  39718. private _lensCenter;
  39719. /**
  39720. * Initializes the VRDistortionCorrectionPostProcess
  39721. * @param name The name of the effect.
  39722. * @param camera The camera to apply the render pass to.
  39723. * @param isRightEye If this is for the right eye distortion
  39724. * @param vrMetrics All the required metrics for the VR camera
  39725. */
  39726. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39727. }
  39728. }
  39729. declare module BABYLON {
  39730. /**
  39731. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39732. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39733. */
  39734. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39735. /**
  39736. * Creates a new VRDeviceOrientationArcRotateCamera
  39737. * @param name defines camera name
  39738. * @param alpha defines the camera rotation along the logitudinal axis
  39739. * @param beta defines the camera rotation along the latitudinal axis
  39740. * @param radius defines the camera distance from its target
  39741. * @param target defines the camera target
  39742. * @param scene defines the scene the camera belongs to
  39743. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39744. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39745. */
  39746. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39747. /**
  39748. * Gets camera class name
  39749. * @returns VRDeviceOrientationArcRotateCamera
  39750. */
  39751. getClassName(): string;
  39752. }
  39753. }
  39754. declare module BABYLON {
  39755. /**
  39756. * Camera used to simulate VR rendering (based on FreeCamera)
  39757. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39758. */
  39759. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39760. /**
  39761. * Creates a new VRDeviceOrientationFreeCamera
  39762. * @param name defines camera name
  39763. * @param position defines the start position of the camera
  39764. * @param scene defines the scene the camera belongs to
  39765. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39766. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39767. */
  39768. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39769. /**
  39770. * Gets camera class name
  39771. * @returns VRDeviceOrientationFreeCamera
  39772. */
  39773. getClassName(): string;
  39774. }
  39775. }
  39776. declare module BABYLON {
  39777. /**
  39778. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39779. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39780. */
  39781. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39782. /**
  39783. * Creates a new VRDeviceOrientationGamepadCamera
  39784. * @param name defines camera name
  39785. * @param position defines the start position of the camera
  39786. * @param scene defines the scene the camera belongs to
  39787. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39788. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39789. */
  39790. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39791. /**
  39792. * Gets camera class name
  39793. * @returns VRDeviceOrientationGamepadCamera
  39794. */
  39795. getClassName(): string;
  39796. }
  39797. }
  39798. declare module BABYLON {
  39799. /**
  39800. * Base class of materials working in push mode in babylon JS
  39801. * @hidden
  39802. */
  39803. export class PushMaterial extends Material {
  39804. protected _activeEffect: Effect;
  39805. protected _normalMatrix: Matrix;
  39806. /**
  39807. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39808. * This means that the material can keep using a previous shader while a new one is being compiled.
  39809. * This is mostly used when shader parallel compilation is supported (true by default)
  39810. */
  39811. allowShaderHotSwapping: boolean;
  39812. constructor(name: string, scene: Scene);
  39813. getEffect(): Effect;
  39814. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39815. /**
  39816. * Binds the given world matrix to the active effect
  39817. *
  39818. * @param world the matrix to bind
  39819. */
  39820. bindOnlyWorldMatrix(world: Matrix): void;
  39821. /**
  39822. * Binds the given normal matrix to the active effect
  39823. *
  39824. * @param normalMatrix the matrix to bind
  39825. */
  39826. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39827. bind(world: Matrix, mesh?: Mesh): void;
  39828. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39829. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39830. }
  39831. }
  39832. declare module BABYLON {
  39833. /**
  39834. * This groups all the flags used to control the materials channel.
  39835. */
  39836. export class MaterialFlags {
  39837. private static _DiffuseTextureEnabled;
  39838. /**
  39839. * Are diffuse textures enabled in the application.
  39840. */
  39841. static DiffuseTextureEnabled: boolean;
  39842. private static _AmbientTextureEnabled;
  39843. /**
  39844. * Are ambient textures enabled in the application.
  39845. */
  39846. static AmbientTextureEnabled: boolean;
  39847. private static _OpacityTextureEnabled;
  39848. /**
  39849. * Are opacity textures enabled in the application.
  39850. */
  39851. static OpacityTextureEnabled: boolean;
  39852. private static _ReflectionTextureEnabled;
  39853. /**
  39854. * Are reflection textures enabled in the application.
  39855. */
  39856. static ReflectionTextureEnabled: boolean;
  39857. private static _EmissiveTextureEnabled;
  39858. /**
  39859. * Are emissive textures enabled in the application.
  39860. */
  39861. static EmissiveTextureEnabled: boolean;
  39862. private static _SpecularTextureEnabled;
  39863. /**
  39864. * Are specular textures enabled in the application.
  39865. */
  39866. static SpecularTextureEnabled: boolean;
  39867. private static _BumpTextureEnabled;
  39868. /**
  39869. * Are bump textures enabled in the application.
  39870. */
  39871. static BumpTextureEnabled: boolean;
  39872. private static _LightmapTextureEnabled;
  39873. /**
  39874. * Are lightmap textures enabled in the application.
  39875. */
  39876. static LightmapTextureEnabled: boolean;
  39877. private static _RefractionTextureEnabled;
  39878. /**
  39879. * Are refraction textures enabled in the application.
  39880. */
  39881. static RefractionTextureEnabled: boolean;
  39882. private static _ColorGradingTextureEnabled;
  39883. /**
  39884. * Are color grading textures enabled in the application.
  39885. */
  39886. static ColorGradingTextureEnabled: boolean;
  39887. private static _FresnelEnabled;
  39888. /**
  39889. * Are fresnels enabled in the application.
  39890. */
  39891. static FresnelEnabled: boolean;
  39892. private static _ClearCoatTextureEnabled;
  39893. /**
  39894. * Are clear coat textures enabled in the application.
  39895. */
  39896. static ClearCoatTextureEnabled: boolean;
  39897. private static _ClearCoatBumpTextureEnabled;
  39898. /**
  39899. * Are clear coat bump textures enabled in the application.
  39900. */
  39901. static ClearCoatBumpTextureEnabled: boolean;
  39902. private static _ClearCoatTintTextureEnabled;
  39903. /**
  39904. * Are clear coat tint textures enabled in the application.
  39905. */
  39906. static ClearCoatTintTextureEnabled: boolean;
  39907. private static _SheenTextureEnabled;
  39908. /**
  39909. * Are sheen textures enabled in the application.
  39910. */
  39911. static SheenTextureEnabled: boolean;
  39912. private static _AnisotropicTextureEnabled;
  39913. /**
  39914. * Are anisotropic textures enabled in the application.
  39915. */
  39916. static AnisotropicTextureEnabled: boolean;
  39917. private static _ThicknessTextureEnabled;
  39918. /**
  39919. * Are thickness textures enabled in the application.
  39920. */
  39921. static ThicknessTextureEnabled: boolean;
  39922. }
  39923. }
  39924. declare module BABYLON {
  39925. /** @hidden */
  39926. export var defaultFragmentDeclaration: {
  39927. name: string;
  39928. shader: string;
  39929. };
  39930. }
  39931. declare module BABYLON {
  39932. /** @hidden */
  39933. export var defaultUboDeclaration: {
  39934. name: string;
  39935. shader: string;
  39936. };
  39937. }
  39938. declare module BABYLON {
  39939. /** @hidden */
  39940. export var lightFragmentDeclaration: {
  39941. name: string;
  39942. shader: string;
  39943. };
  39944. }
  39945. declare module BABYLON {
  39946. /** @hidden */
  39947. export var lightUboDeclaration: {
  39948. name: string;
  39949. shader: string;
  39950. };
  39951. }
  39952. declare module BABYLON {
  39953. /** @hidden */
  39954. export var lightsFragmentFunctions: {
  39955. name: string;
  39956. shader: string;
  39957. };
  39958. }
  39959. declare module BABYLON {
  39960. /** @hidden */
  39961. export var shadowsFragmentFunctions: {
  39962. name: string;
  39963. shader: string;
  39964. };
  39965. }
  39966. declare module BABYLON {
  39967. /** @hidden */
  39968. export var fresnelFunction: {
  39969. name: string;
  39970. shader: string;
  39971. };
  39972. }
  39973. declare module BABYLON {
  39974. /** @hidden */
  39975. export var reflectionFunction: {
  39976. name: string;
  39977. shader: string;
  39978. };
  39979. }
  39980. declare module BABYLON {
  39981. /** @hidden */
  39982. export var bumpFragmentFunctions: {
  39983. name: string;
  39984. shader: string;
  39985. };
  39986. }
  39987. declare module BABYLON {
  39988. /** @hidden */
  39989. export var logDepthDeclaration: {
  39990. name: string;
  39991. shader: string;
  39992. };
  39993. }
  39994. declare module BABYLON {
  39995. /** @hidden */
  39996. export var bumpFragment: {
  39997. name: string;
  39998. shader: string;
  39999. };
  40000. }
  40001. declare module BABYLON {
  40002. /** @hidden */
  40003. export var depthPrePass: {
  40004. name: string;
  40005. shader: string;
  40006. };
  40007. }
  40008. declare module BABYLON {
  40009. /** @hidden */
  40010. export var lightFragment: {
  40011. name: string;
  40012. shader: string;
  40013. };
  40014. }
  40015. declare module BABYLON {
  40016. /** @hidden */
  40017. export var logDepthFragment: {
  40018. name: string;
  40019. shader: string;
  40020. };
  40021. }
  40022. declare module BABYLON {
  40023. /** @hidden */
  40024. export var defaultPixelShader: {
  40025. name: string;
  40026. shader: string;
  40027. };
  40028. }
  40029. declare module BABYLON {
  40030. /** @hidden */
  40031. export var defaultVertexDeclaration: {
  40032. name: string;
  40033. shader: string;
  40034. };
  40035. }
  40036. declare module BABYLON {
  40037. /** @hidden */
  40038. export var bumpVertexDeclaration: {
  40039. name: string;
  40040. shader: string;
  40041. };
  40042. }
  40043. declare module BABYLON {
  40044. /** @hidden */
  40045. export var bumpVertex: {
  40046. name: string;
  40047. shader: string;
  40048. };
  40049. }
  40050. declare module BABYLON {
  40051. /** @hidden */
  40052. export var fogVertex: {
  40053. name: string;
  40054. shader: string;
  40055. };
  40056. }
  40057. declare module BABYLON {
  40058. /** @hidden */
  40059. export var shadowsVertex: {
  40060. name: string;
  40061. shader: string;
  40062. };
  40063. }
  40064. declare module BABYLON {
  40065. /** @hidden */
  40066. export var pointCloudVertex: {
  40067. name: string;
  40068. shader: string;
  40069. };
  40070. }
  40071. declare module BABYLON {
  40072. /** @hidden */
  40073. export var logDepthVertex: {
  40074. name: string;
  40075. shader: string;
  40076. };
  40077. }
  40078. declare module BABYLON {
  40079. /** @hidden */
  40080. export var defaultVertexShader: {
  40081. name: string;
  40082. shader: string;
  40083. };
  40084. }
  40085. declare module BABYLON {
  40086. /** @hidden */
  40087. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40088. MAINUV1: boolean;
  40089. MAINUV2: boolean;
  40090. DIFFUSE: boolean;
  40091. DIFFUSEDIRECTUV: number;
  40092. AMBIENT: boolean;
  40093. AMBIENTDIRECTUV: number;
  40094. OPACITY: boolean;
  40095. OPACITYDIRECTUV: number;
  40096. OPACITYRGB: boolean;
  40097. REFLECTION: boolean;
  40098. EMISSIVE: boolean;
  40099. EMISSIVEDIRECTUV: number;
  40100. SPECULAR: boolean;
  40101. SPECULARDIRECTUV: number;
  40102. BUMP: boolean;
  40103. BUMPDIRECTUV: number;
  40104. PARALLAX: boolean;
  40105. PARALLAXOCCLUSION: boolean;
  40106. SPECULAROVERALPHA: boolean;
  40107. CLIPPLANE: boolean;
  40108. CLIPPLANE2: boolean;
  40109. CLIPPLANE3: boolean;
  40110. CLIPPLANE4: boolean;
  40111. ALPHATEST: boolean;
  40112. DEPTHPREPASS: boolean;
  40113. ALPHAFROMDIFFUSE: boolean;
  40114. POINTSIZE: boolean;
  40115. FOG: boolean;
  40116. SPECULARTERM: boolean;
  40117. DIFFUSEFRESNEL: boolean;
  40118. OPACITYFRESNEL: boolean;
  40119. REFLECTIONFRESNEL: boolean;
  40120. REFRACTIONFRESNEL: boolean;
  40121. EMISSIVEFRESNEL: boolean;
  40122. FRESNEL: boolean;
  40123. NORMAL: boolean;
  40124. UV1: boolean;
  40125. UV2: boolean;
  40126. VERTEXCOLOR: boolean;
  40127. VERTEXALPHA: boolean;
  40128. NUM_BONE_INFLUENCERS: number;
  40129. BonesPerMesh: number;
  40130. BONETEXTURE: boolean;
  40131. INSTANCES: boolean;
  40132. GLOSSINESS: boolean;
  40133. ROUGHNESS: boolean;
  40134. EMISSIVEASILLUMINATION: boolean;
  40135. LINKEMISSIVEWITHDIFFUSE: boolean;
  40136. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40137. LIGHTMAP: boolean;
  40138. LIGHTMAPDIRECTUV: number;
  40139. OBJECTSPACE_NORMALMAP: boolean;
  40140. USELIGHTMAPASSHADOWMAP: boolean;
  40141. REFLECTIONMAP_3D: boolean;
  40142. REFLECTIONMAP_SPHERICAL: boolean;
  40143. REFLECTIONMAP_PLANAR: boolean;
  40144. REFLECTIONMAP_CUBIC: boolean;
  40145. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40146. REFLECTIONMAP_PROJECTION: boolean;
  40147. REFLECTIONMAP_SKYBOX: boolean;
  40148. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40149. REFLECTIONMAP_EXPLICIT: boolean;
  40150. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40151. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40152. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40153. INVERTCUBICMAP: boolean;
  40154. LOGARITHMICDEPTH: boolean;
  40155. REFRACTION: boolean;
  40156. REFRACTIONMAP_3D: boolean;
  40157. REFLECTIONOVERALPHA: boolean;
  40158. TWOSIDEDLIGHTING: boolean;
  40159. SHADOWFLOAT: boolean;
  40160. MORPHTARGETS: boolean;
  40161. MORPHTARGETS_NORMAL: boolean;
  40162. MORPHTARGETS_TANGENT: boolean;
  40163. MORPHTARGETS_UV: boolean;
  40164. NUM_MORPH_INFLUENCERS: number;
  40165. NONUNIFORMSCALING: boolean;
  40166. PREMULTIPLYALPHA: boolean;
  40167. IMAGEPROCESSING: boolean;
  40168. VIGNETTE: boolean;
  40169. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40170. VIGNETTEBLENDMODEOPAQUE: boolean;
  40171. TONEMAPPING: boolean;
  40172. TONEMAPPING_ACES: boolean;
  40173. CONTRAST: boolean;
  40174. COLORCURVES: boolean;
  40175. COLORGRADING: boolean;
  40176. COLORGRADING3D: boolean;
  40177. SAMPLER3DGREENDEPTH: boolean;
  40178. SAMPLER3DBGRMAP: boolean;
  40179. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40180. MULTIVIEW: boolean;
  40181. /**
  40182. * If the reflection texture on this material is in linear color space
  40183. * @hidden
  40184. */
  40185. IS_REFLECTION_LINEAR: boolean;
  40186. /**
  40187. * If the refraction texture on this material is in linear color space
  40188. * @hidden
  40189. */
  40190. IS_REFRACTION_LINEAR: boolean;
  40191. EXPOSURE: boolean;
  40192. constructor();
  40193. setReflectionMode(modeToEnable: string): void;
  40194. }
  40195. /**
  40196. * This is the default material used in Babylon. It is the best trade off between quality
  40197. * and performances.
  40198. * @see http://doc.babylonjs.com/babylon101/materials
  40199. */
  40200. export class StandardMaterial extends PushMaterial {
  40201. private _diffuseTexture;
  40202. /**
  40203. * The basic texture of the material as viewed under a light.
  40204. */
  40205. diffuseTexture: Nullable<BaseTexture>;
  40206. private _ambientTexture;
  40207. /**
  40208. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40209. */
  40210. ambientTexture: Nullable<BaseTexture>;
  40211. private _opacityTexture;
  40212. /**
  40213. * Define the transparency of the material from a texture.
  40214. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40215. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40216. */
  40217. opacityTexture: Nullable<BaseTexture>;
  40218. private _reflectionTexture;
  40219. /**
  40220. * Define the texture used to display the reflection.
  40221. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40222. */
  40223. reflectionTexture: Nullable<BaseTexture>;
  40224. private _emissiveTexture;
  40225. /**
  40226. * Define texture of the material as if self lit.
  40227. * This will be mixed in the final result even in the absence of light.
  40228. */
  40229. emissiveTexture: Nullable<BaseTexture>;
  40230. private _specularTexture;
  40231. /**
  40232. * Define how the color and intensity of the highlight given by the light in the material.
  40233. */
  40234. specularTexture: Nullable<BaseTexture>;
  40235. private _bumpTexture;
  40236. /**
  40237. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40238. * 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.
  40239. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40240. */
  40241. bumpTexture: Nullable<BaseTexture>;
  40242. private _lightmapTexture;
  40243. /**
  40244. * Complex lighting can be computationally expensive to compute at runtime.
  40245. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40246. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40247. */
  40248. lightmapTexture: Nullable<BaseTexture>;
  40249. private _refractionTexture;
  40250. /**
  40251. * Define the texture used to display the refraction.
  40252. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40253. */
  40254. refractionTexture: Nullable<BaseTexture>;
  40255. /**
  40256. * The color of the material lit by the environmental background lighting.
  40257. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40258. */
  40259. ambientColor: Color3;
  40260. /**
  40261. * The basic color of the material as viewed under a light.
  40262. */
  40263. diffuseColor: Color3;
  40264. /**
  40265. * Define how the color and intensity of the highlight given by the light in the material.
  40266. */
  40267. specularColor: Color3;
  40268. /**
  40269. * Define the color of the material as if self lit.
  40270. * This will be mixed in the final result even in the absence of light.
  40271. */
  40272. emissiveColor: Color3;
  40273. /**
  40274. * Defines how sharp are the highlights in the material.
  40275. * The bigger the value the sharper giving a more glossy feeling to the result.
  40276. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40277. */
  40278. specularPower: number;
  40279. private _useAlphaFromDiffuseTexture;
  40280. /**
  40281. * Does the transparency come from the diffuse texture alpha channel.
  40282. */
  40283. useAlphaFromDiffuseTexture: boolean;
  40284. private _useEmissiveAsIllumination;
  40285. /**
  40286. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40287. */
  40288. useEmissiveAsIllumination: boolean;
  40289. private _linkEmissiveWithDiffuse;
  40290. /**
  40291. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40292. * the emissive level when the final color is close to one.
  40293. */
  40294. linkEmissiveWithDiffuse: boolean;
  40295. private _useSpecularOverAlpha;
  40296. /**
  40297. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40298. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40299. */
  40300. useSpecularOverAlpha: boolean;
  40301. private _useReflectionOverAlpha;
  40302. /**
  40303. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40304. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40305. */
  40306. useReflectionOverAlpha: boolean;
  40307. private _disableLighting;
  40308. /**
  40309. * Does lights from the scene impacts this material.
  40310. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40311. */
  40312. disableLighting: boolean;
  40313. private _useObjectSpaceNormalMap;
  40314. /**
  40315. * Allows using an object space normal map (instead of tangent space).
  40316. */
  40317. useObjectSpaceNormalMap: boolean;
  40318. private _useParallax;
  40319. /**
  40320. * Is parallax enabled or not.
  40321. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40322. */
  40323. useParallax: boolean;
  40324. private _useParallaxOcclusion;
  40325. /**
  40326. * Is parallax occlusion enabled or not.
  40327. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40328. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40329. */
  40330. useParallaxOcclusion: boolean;
  40331. /**
  40332. * 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.
  40333. */
  40334. parallaxScaleBias: number;
  40335. private _roughness;
  40336. /**
  40337. * Helps to define how blurry the reflections should appears in the material.
  40338. */
  40339. roughness: number;
  40340. /**
  40341. * In case of refraction, define the value of the index of refraction.
  40342. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40343. */
  40344. indexOfRefraction: number;
  40345. /**
  40346. * Invert the refraction texture alongside the y axis.
  40347. * It can be useful with procedural textures or probe for instance.
  40348. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40349. */
  40350. invertRefractionY: boolean;
  40351. /**
  40352. * Defines the alpha limits in alpha test mode.
  40353. */
  40354. alphaCutOff: number;
  40355. private _useLightmapAsShadowmap;
  40356. /**
  40357. * In case of light mapping, define whether the map contains light or shadow informations.
  40358. */
  40359. useLightmapAsShadowmap: boolean;
  40360. private _diffuseFresnelParameters;
  40361. /**
  40362. * Define the diffuse fresnel parameters of the material.
  40363. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40364. */
  40365. diffuseFresnelParameters: FresnelParameters;
  40366. private _opacityFresnelParameters;
  40367. /**
  40368. * Define the opacity fresnel parameters of the material.
  40369. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40370. */
  40371. opacityFresnelParameters: FresnelParameters;
  40372. private _reflectionFresnelParameters;
  40373. /**
  40374. * Define the reflection fresnel parameters of the material.
  40375. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40376. */
  40377. reflectionFresnelParameters: FresnelParameters;
  40378. private _refractionFresnelParameters;
  40379. /**
  40380. * Define the refraction fresnel parameters of the material.
  40381. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40382. */
  40383. refractionFresnelParameters: FresnelParameters;
  40384. private _emissiveFresnelParameters;
  40385. /**
  40386. * Define the emissive fresnel parameters of the material.
  40387. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40388. */
  40389. emissiveFresnelParameters: FresnelParameters;
  40390. private _useReflectionFresnelFromSpecular;
  40391. /**
  40392. * If true automatically deducts the fresnels values from the material specularity.
  40393. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40394. */
  40395. useReflectionFresnelFromSpecular: boolean;
  40396. private _useGlossinessFromSpecularMapAlpha;
  40397. /**
  40398. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40399. */
  40400. useGlossinessFromSpecularMapAlpha: boolean;
  40401. private _maxSimultaneousLights;
  40402. /**
  40403. * Defines the maximum number of lights that can be used in the material
  40404. */
  40405. maxSimultaneousLights: number;
  40406. private _invertNormalMapX;
  40407. /**
  40408. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40409. */
  40410. invertNormalMapX: boolean;
  40411. private _invertNormalMapY;
  40412. /**
  40413. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40414. */
  40415. invertNormalMapY: boolean;
  40416. private _twoSidedLighting;
  40417. /**
  40418. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40419. */
  40420. twoSidedLighting: boolean;
  40421. /**
  40422. * Default configuration related to image processing available in the standard Material.
  40423. */
  40424. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40425. /**
  40426. * Gets the image processing configuration used either in this material.
  40427. */
  40428. /**
  40429. * Sets the Default image processing configuration used either in the this material.
  40430. *
  40431. * If sets to null, the scene one is in use.
  40432. */
  40433. imageProcessingConfiguration: ImageProcessingConfiguration;
  40434. /**
  40435. * Keep track of the image processing observer to allow dispose and replace.
  40436. */
  40437. private _imageProcessingObserver;
  40438. /**
  40439. * Attaches a new image processing configuration to the Standard Material.
  40440. * @param configuration
  40441. */
  40442. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40443. /**
  40444. * Gets wether the color curves effect is enabled.
  40445. */
  40446. /**
  40447. * Sets wether the color curves effect is enabled.
  40448. */
  40449. cameraColorCurvesEnabled: boolean;
  40450. /**
  40451. * Gets wether the color grading effect is enabled.
  40452. */
  40453. /**
  40454. * Gets wether the color grading effect is enabled.
  40455. */
  40456. cameraColorGradingEnabled: boolean;
  40457. /**
  40458. * Gets wether tonemapping is enabled or not.
  40459. */
  40460. /**
  40461. * Sets wether tonemapping is enabled or not
  40462. */
  40463. cameraToneMappingEnabled: boolean;
  40464. /**
  40465. * The camera exposure used on this material.
  40466. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40467. * This corresponds to a photographic exposure.
  40468. */
  40469. /**
  40470. * The camera exposure used on this material.
  40471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40472. * This corresponds to a photographic exposure.
  40473. */
  40474. cameraExposure: number;
  40475. /**
  40476. * Gets The camera contrast used on this material.
  40477. */
  40478. /**
  40479. * Sets The camera contrast used on this material.
  40480. */
  40481. cameraContrast: number;
  40482. /**
  40483. * Gets the Color Grading 2D Lookup Texture.
  40484. */
  40485. /**
  40486. * Sets the Color Grading 2D Lookup Texture.
  40487. */
  40488. cameraColorGradingTexture: Nullable<BaseTexture>;
  40489. /**
  40490. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40491. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40492. * 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;
  40493. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40494. */
  40495. /**
  40496. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40497. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40498. * 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;
  40499. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40500. */
  40501. cameraColorCurves: Nullable<ColorCurves>;
  40502. /**
  40503. * Custom callback helping to override the default shader used in the material.
  40504. */
  40505. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40506. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40507. protected _worldViewProjectionMatrix: Matrix;
  40508. protected _globalAmbientColor: Color3;
  40509. protected _useLogarithmicDepth: boolean;
  40510. protected _rebuildInParallel: boolean;
  40511. /**
  40512. * Instantiates a new standard material.
  40513. * This is the default material used in Babylon. It is the best trade off between quality
  40514. * and performances.
  40515. * @see http://doc.babylonjs.com/babylon101/materials
  40516. * @param name Define the name of the material in the scene
  40517. * @param scene Define the scene the material belong to
  40518. */
  40519. constructor(name: string, scene: Scene);
  40520. /**
  40521. * Gets a boolean indicating that current material needs to register RTT
  40522. */
  40523. readonly hasRenderTargetTextures: boolean;
  40524. /**
  40525. * Gets the current class name of the material e.g. "StandardMaterial"
  40526. * Mainly use in serialization.
  40527. * @returns the class name
  40528. */
  40529. getClassName(): string;
  40530. /**
  40531. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40532. * You can try switching to logarithmic depth.
  40533. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40534. */
  40535. useLogarithmicDepth: boolean;
  40536. /**
  40537. * Specifies if the material will require alpha blending
  40538. * @returns a boolean specifying if alpha blending is needed
  40539. */
  40540. needAlphaBlending(): boolean;
  40541. /**
  40542. * Specifies if this material should be rendered in alpha test mode
  40543. * @returns a boolean specifying if an alpha test is needed.
  40544. */
  40545. needAlphaTesting(): boolean;
  40546. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40547. /**
  40548. * Get the texture used for alpha test purpose.
  40549. * @returns the diffuse texture in case of the standard material.
  40550. */
  40551. getAlphaTestTexture(): Nullable<BaseTexture>;
  40552. /**
  40553. * Get if the submesh is ready to be used and all its information available.
  40554. * Child classes can use it to update shaders
  40555. * @param mesh defines the mesh to check
  40556. * @param subMesh defines which submesh to check
  40557. * @param useInstances specifies that instances should be used
  40558. * @returns a boolean indicating that the submesh is ready or not
  40559. */
  40560. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40561. /**
  40562. * Builds the material UBO layouts.
  40563. * Used internally during the effect preparation.
  40564. */
  40565. buildUniformLayout(): void;
  40566. /**
  40567. * Unbinds the material from the mesh
  40568. */
  40569. unbind(): void;
  40570. /**
  40571. * Binds the submesh to this material by preparing the effect and shader to draw
  40572. * @param world defines the world transformation matrix
  40573. * @param mesh defines the mesh containing the submesh
  40574. * @param subMesh defines the submesh to bind the material to
  40575. */
  40576. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40577. /**
  40578. * Get the list of animatables in the material.
  40579. * @returns the list of animatables object used in the material
  40580. */
  40581. getAnimatables(): IAnimatable[];
  40582. /**
  40583. * Gets the active textures from the material
  40584. * @returns an array of textures
  40585. */
  40586. getActiveTextures(): BaseTexture[];
  40587. /**
  40588. * Specifies if the material uses a texture
  40589. * @param texture defines the texture to check against the material
  40590. * @returns a boolean specifying if the material uses the texture
  40591. */
  40592. hasTexture(texture: BaseTexture): boolean;
  40593. /**
  40594. * Disposes the material
  40595. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40596. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40597. */
  40598. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40599. /**
  40600. * Makes a duplicate of the material, and gives it a new name
  40601. * @param name defines the new name for the duplicated material
  40602. * @returns the cloned material
  40603. */
  40604. clone(name: string): StandardMaterial;
  40605. /**
  40606. * Serializes this material in a JSON representation
  40607. * @returns the serialized material object
  40608. */
  40609. serialize(): any;
  40610. /**
  40611. * Creates a standard material from parsed material data
  40612. * @param source defines the JSON representation of the material
  40613. * @param scene defines the hosting scene
  40614. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40615. * @returns a new standard material
  40616. */
  40617. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40618. /**
  40619. * Are diffuse textures enabled in the application.
  40620. */
  40621. static DiffuseTextureEnabled: boolean;
  40622. /**
  40623. * Are ambient textures enabled in the application.
  40624. */
  40625. static AmbientTextureEnabled: boolean;
  40626. /**
  40627. * Are opacity textures enabled in the application.
  40628. */
  40629. static OpacityTextureEnabled: boolean;
  40630. /**
  40631. * Are reflection textures enabled in the application.
  40632. */
  40633. static ReflectionTextureEnabled: boolean;
  40634. /**
  40635. * Are emissive textures enabled in the application.
  40636. */
  40637. static EmissiveTextureEnabled: boolean;
  40638. /**
  40639. * Are specular textures enabled in the application.
  40640. */
  40641. static SpecularTextureEnabled: boolean;
  40642. /**
  40643. * Are bump textures enabled in the application.
  40644. */
  40645. static BumpTextureEnabled: boolean;
  40646. /**
  40647. * Are lightmap textures enabled in the application.
  40648. */
  40649. static LightmapTextureEnabled: boolean;
  40650. /**
  40651. * Are refraction textures enabled in the application.
  40652. */
  40653. static RefractionTextureEnabled: boolean;
  40654. /**
  40655. * Are color grading textures enabled in the application.
  40656. */
  40657. static ColorGradingTextureEnabled: boolean;
  40658. /**
  40659. * Are fresnels enabled in the application.
  40660. */
  40661. static FresnelEnabled: boolean;
  40662. }
  40663. }
  40664. declare module BABYLON {
  40665. /** @hidden */
  40666. export var imageProcessingPixelShader: {
  40667. name: string;
  40668. shader: string;
  40669. };
  40670. }
  40671. declare module BABYLON {
  40672. /**
  40673. * ImageProcessingPostProcess
  40674. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40675. */
  40676. export class ImageProcessingPostProcess extends PostProcess {
  40677. /**
  40678. * Default configuration related to image processing available in the PBR Material.
  40679. */
  40680. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40681. /**
  40682. * Gets the image processing configuration used either in this material.
  40683. */
  40684. /**
  40685. * Sets the Default image processing configuration used either in the this material.
  40686. *
  40687. * If sets to null, the scene one is in use.
  40688. */
  40689. imageProcessingConfiguration: ImageProcessingConfiguration;
  40690. /**
  40691. * Keep track of the image processing observer to allow dispose and replace.
  40692. */
  40693. private _imageProcessingObserver;
  40694. /**
  40695. * Attaches a new image processing configuration to the PBR Material.
  40696. * @param configuration
  40697. */
  40698. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40699. /**
  40700. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40701. */
  40702. /**
  40703. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40704. */
  40705. colorCurves: Nullable<ColorCurves>;
  40706. /**
  40707. * Gets wether the color curves effect is enabled.
  40708. */
  40709. /**
  40710. * Sets wether the color curves effect is enabled.
  40711. */
  40712. colorCurvesEnabled: boolean;
  40713. /**
  40714. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40715. */
  40716. /**
  40717. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40718. */
  40719. colorGradingTexture: Nullable<BaseTexture>;
  40720. /**
  40721. * Gets wether the color grading effect is enabled.
  40722. */
  40723. /**
  40724. * Gets wether the color grading effect is enabled.
  40725. */
  40726. colorGradingEnabled: boolean;
  40727. /**
  40728. * Gets exposure used in the effect.
  40729. */
  40730. /**
  40731. * Sets exposure used in the effect.
  40732. */
  40733. exposure: number;
  40734. /**
  40735. * Gets wether tonemapping is enabled or not.
  40736. */
  40737. /**
  40738. * Sets wether tonemapping is enabled or not
  40739. */
  40740. toneMappingEnabled: boolean;
  40741. /**
  40742. * Gets the type of tone mapping effect.
  40743. */
  40744. /**
  40745. * Sets the type of tone mapping effect.
  40746. */
  40747. toneMappingType: number;
  40748. /**
  40749. * Gets contrast used in the effect.
  40750. */
  40751. /**
  40752. * Sets contrast used in the effect.
  40753. */
  40754. contrast: number;
  40755. /**
  40756. * Gets Vignette stretch size.
  40757. */
  40758. /**
  40759. * Sets Vignette stretch size.
  40760. */
  40761. vignetteStretch: number;
  40762. /**
  40763. * Gets Vignette centre X Offset.
  40764. */
  40765. /**
  40766. * Sets Vignette centre X Offset.
  40767. */
  40768. vignetteCentreX: number;
  40769. /**
  40770. * Gets Vignette centre Y Offset.
  40771. */
  40772. /**
  40773. * Sets Vignette centre Y Offset.
  40774. */
  40775. vignetteCentreY: number;
  40776. /**
  40777. * Gets Vignette weight or intensity of the vignette effect.
  40778. */
  40779. /**
  40780. * Sets Vignette weight or intensity of the vignette effect.
  40781. */
  40782. vignetteWeight: number;
  40783. /**
  40784. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40785. * if vignetteEnabled is set to true.
  40786. */
  40787. /**
  40788. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40789. * if vignetteEnabled is set to true.
  40790. */
  40791. vignetteColor: Color4;
  40792. /**
  40793. * Gets Camera field of view used by the Vignette effect.
  40794. */
  40795. /**
  40796. * Sets Camera field of view used by the Vignette effect.
  40797. */
  40798. vignetteCameraFov: number;
  40799. /**
  40800. * Gets the vignette blend mode allowing different kind of effect.
  40801. */
  40802. /**
  40803. * Sets the vignette blend mode allowing different kind of effect.
  40804. */
  40805. vignetteBlendMode: number;
  40806. /**
  40807. * Gets wether the vignette effect is enabled.
  40808. */
  40809. /**
  40810. * Sets wether the vignette effect is enabled.
  40811. */
  40812. vignetteEnabled: boolean;
  40813. private _fromLinearSpace;
  40814. /**
  40815. * Gets wether the input of the processing is in Gamma or Linear Space.
  40816. */
  40817. /**
  40818. * Sets wether the input of the processing is in Gamma or Linear Space.
  40819. */
  40820. fromLinearSpace: boolean;
  40821. /**
  40822. * Defines cache preventing GC.
  40823. */
  40824. private _defines;
  40825. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40826. /**
  40827. * "ImageProcessingPostProcess"
  40828. * @returns "ImageProcessingPostProcess"
  40829. */
  40830. getClassName(): string;
  40831. protected _updateParameters(): void;
  40832. dispose(camera?: Camera): void;
  40833. }
  40834. }
  40835. declare module BABYLON {
  40836. /**
  40837. * Class containing static functions to help procedurally build meshes
  40838. */
  40839. export class GroundBuilder {
  40840. /**
  40841. * Creates a ground mesh
  40842. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40843. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40845. * @param name defines the name of the mesh
  40846. * @param options defines the options used to create the mesh
  40847. * @param scene defines the hosting scene
  40848. * @returns the ground mesh
  40849. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40850. */
  40851. static CreateGround(name: string, options: {
  40852. width?: number;
  40853. height?: number;
  40854. subdivisions?: number;
  40855. subdivisionsX?: number;
  40856. subdivisionsY?: number;
  40857. updatable?: boolean;
  40858. }, scene: any): Mesh;
  40859. /**
  40860. * Creates a tiled ground mesh
  40861. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40862. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40863. * * 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
  40864. * * 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
  40865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40866. * @param name defines the name of the mesh
  40867. * @param options defines the options used to create the mesh
  40868. * @param scene defines the hosting scene
  40869. * @returns the tiled ground mesh
  40870. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40871. */
  40872. static CreateTiledGround(name: string, options: {
  40873. xmin: number;
  40874. zmin: number;
  40875. xmax: number;
  40876. zmax: number;
  40877. subdivisions?: {
  40878. w: number;
  40879. h: number;
  40880. };
  40881. precision?: {
  40882. w: number;
  40883. h: number;
  40884. };
  40885. updatable?: boolean;
  40886. }, scene?: Nullable<Scene>): Mesh;
  40887. /**
  40888. * Creates a ground mesh from a height map
  40889. * * The parameter `url` sets the URL of the height map image resource.
  40890. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40891. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40892. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40893. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40894. * * 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.
  40895. * * 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).
  40896. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40898. * @param name defines the name of the mesh
  40899. * @param url defines the url to the height map
  40900. * @param options defines the options used to create the mesh
  40901. * @param scene defines the hosting scene
  40902. * @returns the ground mesh
  40903. * @see https://doc.babylonjs.com/babylon101/height_map
  40904. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40905. */
  40906. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40907. width?: number;
  40908. height?: number;
  40909. subdivisions?: number;
  40910. minHeight?: number;
  40911. maxHeight?: number;
  40912. colorFilter?: Color3;
  40913. alphaFilter?: number;
  40914. updatable?: boolean;
  40915. onReady?: (mesh: GroundMesh) => void;
  40916. }, scene?: Nullable<Scene>): GroundMesh;
  40917. }
  40918. }
  40919. declare module BABYLON {
  40920. /**
  40921. * Class containing static functions to help procedurally build meshes
  40922. */
  40923. export class TorusBuilder {
  40924. /**
  40925. * Creates a torus mesh
  40926. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40927. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40928. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40930. * * 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
  40931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40932. * @param name defines the name of the mesh
  40933. * @param options defines the options used to create the mesh
  40934. * @param scene defines the hosting scene
  40935. * @returns the torus mesh
  40936. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40937. */
  40938. static CreateTorus(name: string, options: {
  40939. diameter?: number;
  40940. thickness?: number;
  40941. tessellation?: number;
  40942. updatable?: boolean;
  40943. sideOrientation?: number;
  40944. frontUVs?: Vector4;
  40945. backUVs?: Vector4;
  40946. }, scene: any): Mesh;
  40947. }
  40948. }
  40949. declare module BABYLON {
  40950. /**
  40951. * Class containing static functions to help procedurally build meshes
  40952. */
  40953. export class CylinderBuilder {
  40954. /**
  40955. * Creates a cylinder or a cone mesh
  40956. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40957. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40958. * * 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.
  40959. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40960. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40961. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40962. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40963. * * 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).
  40964. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40965. * * 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).
  40966. * * 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
  40967. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40968. * * 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
  40969. * * 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.
  40970. * * If `enclose` is false, a ring surface is one element.
  40971. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40972. * * 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
  40973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40974. * * 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
  40975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40976. * @param name defines the name of the mesh
  40977. * @param options defines the options used to create the mesh
  40978. * @param scene defines the hosting scene
  40979. * @returns the cylinder mesh
  40980. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40981. */
  40982. static CreateCylinder(name: string, options: {
  40983. height?: number;
  40984. diameterTop?: number;
  40985. diameterBottom?: number;
  40986. diameter?: number;
  40987. tessellation?: number;
  40988. subdivisions?: number;
  40989. arc?: number;
  40990. faceColors?: Color4[];
  40991. faceUV?: Vector4[];
  40992. updatable?: boolean;
  40993. hasRings?: boolean;
  40994. enclose?: boolean;
  40995. cap?: number;
  40996. sideOrientation?: number;
  40997. frontUVs?: Vector4;
  40998. backUVs?: Vector4;
  40999. }, scene: any): Mesh;
  41000. }
  41001. }
  41002. declare module BABYLON {
  41003. /**
  41004. * Options to modify the vr teleportation behavior.
  41005. */
  41006. export interface VRTeleportationOptions {
  41007. /**
  41008. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41009. */
  41010. floorMeshName?: string;
  41011. /**
  41012. * A list of meshes to be used as the teleportation floor. (default: empty)
  41013. */
  41014. floorMeshes?: Mesh[];
  41015. }
  41016. /**
  41017. * Options to modify the vr experience helper's behavior.
  41018. */
  41019. export interface VRExperienceHelperOptions extends WebVROptions {
  41020. /**
  41021. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41022. */
  41023. createDeviceOrientationCamera?: boolean;
  41024. /**
  41025. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41026. */
  41027. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41028. /**
  41029. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41030. */
  41031. laserToggle?: boolean;
  41032. /**
  41033. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41034. */
  41035. floorMeshes?: Mesh[];
  41036. /**
  41037. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41038. */
  41039. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41040. }
  41041. /**
  41042. * Event containing information after VR has been entered
  41043. */
  41044. export class OnAfterEnteringVRObservableEvent {
  41045. /**
  41046. * If entering vr was successful
  41047. */
  41048. success: boolean;
  41049. }
  41050. /**
  41051. * Helps to quickly add VR support to an existing scene.
  41052. * See http://doc.babylonjs.com/how_to/webvr_helper
  41053. */
  41054. export class VRExperienceHelper {
  41055. /** Options to modify the vr experience helper's behavior. */
  41056. webVROptions: VRExperienceHelperOptions;
  41057. private _scene;
  41058. private _position;
  41059. private _btnVR;
  41060. private _btnVRDisplayed;
  41061. private _webVRsupported;
  41062. private _webVRready;
  41063. private _webVRrequesting;
  41064. private _webVRpresenting;
  41065. private _hasEnteredVR;
  41066. private _fullscreenVRpresenting;
  41067. private _canvas;
  41068. private _webVRCamera;
  41069. private _vrDeviceOrientationCamera;
  41070. private _deviceOrientationCamera;
  41071. private _existingCamera;
  41072. private _onKeyDown;
  41073. private _onVrDisplayPresentChange;
  41074. private _onVRDisplayChanged;
  41075. private _onVRRequestPresentStart;
  41076. private _onVRRequestPresentComplete;
  41077. /**
  41078. * 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)
  41079. */
  41080. enableGazeEvenWhenNoPointerLock: boolean;
  41081. /**
  41082. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41083. */
  41084. exitVROnDoubleTap: boolean;
  41085. /**
  41086. * Observable raised right before entering VR.
  41087. */
  41088. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41089. /**
  41090. * Observable raised when entering VR has completed.
  41091. */
  41092. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41093. /**
  41094. * Observable raised when exiting VR.
  41095. */
  41096. onExitingVRObservable: Observable<VRExperienceHelper>;
  41097. /**
  41098. * Observable raised when controller mesh is loaded.
  41099. */
  41100. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41101. /** Return this.onEnteringVRObservable
  41102. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41103. */
  41104. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41105. /** Return this.onExitingVRObservable
  41106. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41107. */
  41108. readonly onExitingVR: Observable<VRExperienceHelper>;
  41109. /** Return this.onControllerMeshLoadedObservable
  41110. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41111. */
  41112. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41113. private _rayLength;
  41114. private _useCustomVRButton;
  41115. private _teleportationRequested;
  41116. private _teleportActive;
  41117. private _floorMeshName;
  41118. private _floorMeshesCollection;
  41119. private _rotationAllowed;
  41120. private _teleportBackwardsVector;
  41121. private _teleportationTarget;
  41122. private _isDefaultTeleportationTarget;
  41123. private _postProcessMove;
  41124. private _teleportationFillColor;
  41125. private _teleportationBorderColor;
  41126. private _rotationAngle;
  41127. private _haloCenter;
  41128. private _cameraGazer;
  41129. private _padSensibilityUp;
  41130. private _padSensibilityDown;
  41131. private _leftController;
  41132. private _rightController;
  41133. /**
  41134. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41135. */
  41136. onNewMeshSelected: Observable<AbstractMesh>;
  41137. /**
  41138. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  41139. * This observable will provide the mesh and the controller used to select the mesh
  41140. */
  41141. onMeshSelectedWithController: Observable<{
  41142. mesh: AbstractMesh;
  41143. controller: WebVRController;
  41144. }>;
  41145. /**
  41146. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41147. */
  41148. onNewMeshPicked: Observable<PickingInfo>;
  41149. private _circleEase;
  41150. /**
  41151. * Observable raised before camera teleportation
  41152. */
  41153. onBeforeCameraTeleport: Observable<Vector3>;
  41154. /**
  41155. * Observable raised after camera teleportation
  41156. */
  41157. onAfterCameraTeleport: Observable<Vector3>;
  41158. /**
  41159. * Observable raised when current selected mesh gets unselected
  41160. */
  41161. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41162. private _raySelectionPredicate;
  41163. /**
  41164. * To be optionaly changed by user to define custom ray selection
  41165. */
  41166. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41167. /**
  41168. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41169. */
  41170. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41171. /**
  41172. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41173. */
  41174. teleportationEnabled: boolean;
  41175. private _defaultHeight;
  41176. private _teleportationInitialized;
  41177. private _interactionsEnabled;
  41178. private _interactionsRequested;
  41179. private _displayGaze;
  41180. private _displayLaserPointer;
  41181. /**
  41182. * The mesh used to display where the user is going to teleport.
  41183. */
  41184. /**
  41185. * Sets the mesh to be used to display where the user is going to teleport.
  41186. */
  41187. teleportationTarget: Mesh;
  41188. /**
  41189. * 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
  41190. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41191. * See http://doc.babylonjs.com/resources/baking_transformations
  41192. */
  41193. gazeTrackerMesh: Mesh;
  41194. /**
  41195. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41196. */
  41197. updateGazeTrackerScale: boolean;
  41198. /**
  41199. * If the gaze trackers color should be updated when selecting meshes
  41200. */
  41201. updateGazeTrackerColor: boolean;
  41202. /**
  41203. * If the controller laser color should be updated when selecting meshes
  41204. */
  41205. updateControllerLaserColor: boolean;
  41206. /**
  41207. * The gaze tracking mesh corresponding to the left controller
  41208. */
  41209. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41210. /**
  41211. * The gaze tracking mesh corresponding to the right controller
  41212. */
  41213. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41214. /**
  41215. * If the ray of the gaze should be displayed.
  41216. */
  41217. /**
  41218. * Sets if the ray of the gaze should be displayed.
  41219. */
  41220. displayGaze: boolean;
  41221. /**
  41222. * If the ray of the LaserPointer should be displayed.
  41223. */
  41224. /**
  41225. * Sets if the ray of the LaserPointer should be displayed.
  41226. */
  41227. displayLaserPointer: boolean;
  41228. /**
  41229. * The deviceOrientationCamera used as the camera when not in VR.
  41230. */
  41231. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41232. /**
  41233. * Based on the current WebVR support, returns the current VR camera used.
  41234. */
  41235. readonly currentVRCamera: Nullable<Camera>;
  41236. /**
  41237. * The webVRCamera which is used when in VR.
  41238. */
  41239. readonly webVRCamera: WebVRFreeCamera;
  41240. /**
  41241. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41242. */
  41243. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41244. /**
  41245. * The html button that is used to trigger entering into VR.
  41246. */
  41247. readonly vrButton: Nullable<HTMLButtonElement>;
  41248. private readonly _teleportationRequestInitiated;
  41249. /**
  41250. * Defines wether or not Pointer lock should be requested when switching to
  41251. * full screen.
  41252. */
  41253. requestPointerLockOnFullScreen: boolean;
  41254. /**
  41255. * Instantiates a VRExperienceHelper.
  41256. * Helps to quickly add VR support to an existing scene.
  41257. * @param scene The scene the VRExperienceHelper belongs to.
  41258. * @param webVROptions Options to modify the vr experience helper's behavior.
  41259. */
  41260. constructor(scene: Scene,
  41261. /** Options to modify the vr experience helper's behavior. */
  41262. webVROptions?: VRExperienceHelperOptions);
  41263. private _onDefaultMeshLoaded;
  41264. private _onResize;
  41265. private _onFullscreenChange;
  41266. /**
  41267. * Gets a value indicating if we are currently in VR mode.
  41268. */
  41269. readonly isInVRMode: boolean;
  41270. private onVrDisplayPresentChange;
  41271. private onVRDisplayChanged;
  41272. private moveButtonToBottomRight;
  41273. private displayVRButton;
  41274. private updateButtonVisibility;
  41275. private _cachedAngularSensibility;
  41276. /**
  41277. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41278. * Otherwise, will use the fullscreen API.
  41279. */
  41280. enterVR(): void;
  41281. /**
  41282. * Attempt to exit VR, or fullscreen.
  41283. */
  41284. exitVR(): void;
  41285. /**
  41286. * The position of the vr experience helper.
  41287. */
  41288. /**
  41289. * Sets the position of the vr experience helper.
  41290. */
  41291. position: Vector3;
  41292. /**
  41293. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41294. */
  41295. enableInteractions(): void;
  41296. private readonly _noControllerIsActive;
  41297. private beforeRender;
  41298. private _isTeleportationFloor;
  41299. /**
  41300. * Adds a floor mesh to be used for teleportation.
  41301. * @param floorMesh the mesh to be used for teleportation.
  41302. */
  41303. addFloorMesh(floorMesh: Mesh): void;
  41304. /**
  41305. * Removes a floor mesh from being used for teleportation.
  41306. * @param floorMesh the mesh to be removed.
  41307. */
  41308. removeFloorMesh(floorMesh: Mesh): void;
  41309. /**
  41310. * Enables interactions and teleportation using the VR controllers and gaze.
  41311. * @param vrTeleportationOptions options to modify teleportation behavior.
  41312. */
  41313. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41314. private _onNewGamepadConnected;
  41315. private _tryEnableInteractionOnController;
  41316. private _onNewGamepadDisconnected;
  41317. private _enableInteractionOnController;
  41318. private _checkTeleportWithRay;
  41319. private _checkRotate;
  41320. private _checkTeleportBackwards;
  41321. private _enableTeleportationOnController;
  41322. private _createTeleportationCircles;
  41323. private _displayTeleportationTarget;
  41324. private _hideTeleportationTarget;
  41325. private _rotateCamera;
  41326. private _moveTeleportationSelectorTo;
  41327. private _workingVector;
  41328. private _workingQuaternion;
  41329. private _workingMatrix;
  41330. /**
  41331. * Teleports the users feet to the desired location
  41332. * @param location The location where the user's feet should be placed
  41333. */
  41334. teleportCamera(location: Vector3): void;
  41335. private _convertNormalToDirectionOfRay;
  41336. private _castRayAndSelectObject;
  41337. private _notifySelectedMeshUnselected;
  41338. /**
  41339. * Sets the color of the laser ray from the vr controllers.
  41340. * @param color new color for the ray.
  41341. */
  41342. changeLaserColor(color: Color3): void;
  41343. /**
  41344. * Sets the color of the ray from the vr headsets gaze.
  41345. * @param color new color for the ray.
  41346. */
  41347. changeGazeColor(color: Color3): void;
  41348. /**
  41349. * Exits VR and disposes of the vr experience helper
  41350. */
  41351. dispose(): void;
  41352. /**
  41353. * Gets the name of the VRExperienceHelper class
  41354. * @returns "VRExperienceHelper"
  41355. */
  41356. getClassName(): string;
  41357. }
  41358. }
  41359. declare module BABYLON {
  41360. /**
  41361. * Manages an XRSession to work with Babylon's engine
  41362. * @see https://doc.babylonjs.com/how_to/webxr
  41363. */
  41364. export class WebXRSessionManager implements IDisposable {
  41365. private scene;
  41366. /**
  41367. * Fires every time a new xrFrame arrives which can be used to update the camera
  41368. */
  41369. onXRFrameObservable: Observable<any>;
  41370. /**
  41371. * Fires when the xr session is ended either by the device or manually done
  41372. */
  41373. onXRSessionEnded: Observable<any>;
  41374. /**
  41375. * Underlying xr session
  41376. */
  41377. session: XRSession;
  41378. /**
  41379. * Type of reference space used when creating the session
  41380. */
  41381. referenceSpace: XRReferenceSpace;
  41382. /** @hidden */
  41383. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41384. /**
  41385. * Current XR frame
  41386. */
  41387. currentFrame: Nullable<XRFrame>;
  41388. private _xrNavigator;
  41389. private baseLayer;
  41390. /**
  41391. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41392. * @param scene The scene which the session should be created for
  41393. */
  41394. constructor(scene: Scene);
  41395. /**
  41396. * Initializes the manager
  41397. * After initialization enterXR can be called to start an XR session
  41398. * @returns Promise which resolves after it is initialized
  41399. */
  41400. initializeAsync(): Promise<void>;
  41401. /**
  41402. * Initializes an xr session
  41403. * @param xrSessionMode mode to initialize
  41404. * @returns a promise which will resolve once the session has been initialized
  41405. */
  41406. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  41407. /**
  41408. * Sets the reference space on the xr session
  41409. * @param referenceSpace space to set
  41410. * @returns a promise that will resolve once the reference space has been set
  41411. */
  41412. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  41413. /**
  41414. * Updates the render state of the session
  41415. * @param state state to set
  41416. * @returns a promise that resolves once the render state has been updated
  41417. */
  41418. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  41419. /**
  41420. * Starts rendering to the xr layer
  41421. * @returns a promise that will resolve once rendering has started
  41422. */
  41423. startRenderingToXRAsync(): Promise<void>;
  41424. /**
  41425. * Stops the xrSession and restores the renderloop
  41426. * @returns Promise which resolves after it exits XR
  41427. */
  41428. exitXRAsync(): Promise<unknown>;
  41429. /**
  41430. * Checks if a session would be supported for the creation options specified
  41431. * @param sessionMode session mode to check if supported eg. immersive-vr
  41432. * @returns true if supported
  41433. */
  41434. supportsSessionAsync(sessionMode: XRSessionMode): any;
  41435. /**
  41436. * @hidden
  41437. * Converts the render layer of xrSession to a render target
  41438. * @param session session to create render target for
  41439. * @param scene scene the new render target should be created for
  41440. */
  41441. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  41442. /**
  41443. * Disposes of the session manager
  41444. */
  41445. dispose(): void;
  41446. }
  41447. }
  41448. declare module BABYLON {
  41449. /**
  41450. * WebXR Camera which holds the views for the xrSession
  41451. * @see https://doc.babylonjs.com/how_to/webxr
  41452. */
  41453. export class WebXRCamera extends FreeCamera {
  41454. private static _TmpMatrix;
  41455. /**
  41456. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41457. * @param name the name of the camera
  41458. * @param scene the scene to add the camera to
  41459. */
  41460. constructor(name: string, scene: Scene);
  41461. private _updateNumberOfRigCameras;
  41462. /** @hidden */
  41463. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41464. /**
  41465. * Updates the cameras position from the current pose information of the XR session
  41466. * @param xrSessionManager the session containing pose information
  41467. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41468. */
  41469. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41470. }
  41471. }
  41472. declare module BABYLON {
  41473. /**
  41474. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41475. */
  41476. export class WebXRManagedOutputCanvas implements IDisposable {
  41477. private helper;
  41478. private _canvas;
  41479. /**
  41480. * xrpresent context of the canvas which can be used to display/mirror xr content
  41481. */
  41482. canvasContext: WebGLRenderingContext;
  41483. /**
  41484. * xr layer for the canvas
  41485. */
  41486. xrLayer: Nullable<XRWebGLLayer>;
  41487. /**
  41488. * Initializes the xr layer for the session
  41489. * @param xrSession xr session
  41490. * @returns a promise that will resolve once the XR Layer has been created
  41491. */
  41492. initializeXRLayerAsync(xrSession: any): any;
  41493. /**
  41494. * Initializes the canvas to be added/removed upon entering/exiting xr
  41495. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41496. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41497. */
  41498. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41499. /**
  41500. * Disposes of the object
  41501. */
  41502. dispose(): void;
  41503. private _setManagedOutputCanvas;
  41504. private _addCanvas;
  41505. private _removeCanvas;
  41506. }
  41507. }
  41508. declare module BABYLON {
  41509. /**
  41510. * States of the webXR experience
  41511. */
  41512. export enum WebXRState {
  41513. /**
  41514. * Transitioning to being in XR mode
  41515. */
  41516. ENTERING_XR = 0,
  41517. /**
  41518. * Transitioning to non XR mode
  41519. */
  41520. EXITING_XR = 1,
  41521. /**
  41522. * In XR mode and presenting
  41523. */
  41524. IN_XR = 2,
  41525. /**
  41526. * Not entered XR mode
  41527. */
  41528. NOT_IN_XR = 3
  41529. }
  41530. /**
  41531. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  41532. * @see https://doc.babylonjs.com/how_to/webxr
  41533. */
  41534. export class WebXRExperienceHelper implements IDisposable {
  41535. private scene;
  41536. /**
  41537. * 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
  41538. */
  41539. container: AbstractMesh;
  41540. /**
  41541. * Camera used to render xr content
  41542. */
  41543. camera: WebXRCamera;
  41544. /**
  41545. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41546. */
  41547. state: WebXRState;
  41548. private _setState;
  41549. private static _TmpVector;
  41550. /**
  41551. * Fires when the state of the experience helper has changed
  41552. */
  41553. onStateChangedObservable: Observable<WebXRState>;
  41554. /** Session manager used to keep track of xr session */
  41555. sessionManager: WebXRSessionManager;
  41556. private _nonVRCamera;
  41557. private _originalSceneAutoClear;
  41558. private _supported;
  41559. /**
  41560. * Creates the experience helper
  41561. * @param scene the scene to attach the experience helper to
  41562. * @returns a promise for the experience helper
  41563. */
  41564. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41565. /**
  41566. * Creates a WebXRExperienceHelper
  41567. * @param scene The scene the helper should be created in
  41568. */
  41569. private constructor();
  41570. /**
  41571. * Exits XR mode and returns the scene to its original state
  41572. * @returns promise that resolves after xr mode has exited
  41573. */
  41574. exitXRAsync(): Promise<unknown>;
  41575. /**
  41576. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41577. * @param sessionCreationOptions options for the XR session
  41578. * @param referenceSpaceType frame of reference of the XR session
  41579. * @param outputCanvas the output canvas that will be used to enter XR mode
  41580. * @returns promise that resolves after xr mode has entered
  41581. */
  41582. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  41583. /**
  41584. * Updates the global position of the camera by moving the camera's container
  41585. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41586. * @param position The desired global position of the camera
  41587. */
  41588. setPositionOfCameraUsingContainer(position: Vector3): void;
  41589. /**
  41590. * Rotates the xr camera by rotating the camera's container around the camera's position
  41591. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41592. * @param rotation the desired quaternion rotation to apply to the camera
  41593. */
  41594. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41595. /**
  41596. * Disposes of the experience helper
  41597. */
  41598. dispose(): void;
  41599. }
  41600. }
  41601. declare module BABYLON {
  41602. /**
  41603. * Button which can be used to enter a different mode of XR
  41604. */
  41605. export class WebXREnterExitUIButton {
  41606. /** button element */
  41607. element: HTMLElement;
  41608. /** XR initialization options for the button */
  41609. sessionMode: XRSessionMode;
  41610. /** Reference space type */
  41611. referenceSpaceType: XRReferenceSpaceType;
  41612. /**
  41613. * Creates a WebXREnterExitUIButton
  41614. * @param element button element
  41615. * @param sessionMode XR initialization session mode
  41616. * @param referenceSpaceType the type of reference space to be used
  41617. */
  41618. constructor(
  41619. /** button element */
  41620. element: HTMLElement,
  41621. /** XR initialization options for the button */
  41622. sessionMode: XRSessionMode,
  41623. /** Reference space type */
  41624. referenceSpaceType: XRReferenceSpaceType);
  41625. /**
  41626. * Overwritable function which can be used to update the button's visuals when the state changes
  41627. * @param activeButton the current active button in the UI
  41628. */
  41629. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41630. }
  41631. /**
  41632. * Options to create the webXR UI
  41633. */
  41634. export class WebXREnterExitUIOptions {
  41635. /**
  41636. * Context to enter xr with
  41637. */
  41638. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  41639. /**
  41640. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41641. */
  41642. customButtons?: Array<WebXREnterExitUIButton>;
  41643. }
  41644. /**
  41645. * UI to allow the user to enter/exit XR mode
  41646. */
  41647. export class WebXREnterExitUI implements IDisposable {
  41648. private scene;
  41649. private _overlay;
  41650. private _buttons;
  41651. private _activeButton;
  41652. /**
  41653. * Fired every time the active button is changed.
  41654. *
  41655. * When xr is entered via a button that launches xr that button will be the callback parameter
  41656. *
  41657. * When exiting xr the callback parameter will be null)
  41658. */
  41659. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41660. /**
  41661. * Creates UI to allow the user to enter/exit XR mode
  41662. * @param scene the scene to add the ui to
  41663. * @param helper the xr experience helper to enter/exit xr with
  41664. * @param options options to configure the UI
  41665. * @returns the created ui
  41666. */
  41667. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41668. private constructor();
  41669. private _updateButtons;
  41670. /**
  41671. * Disposes of the object
  41672. */
  41673. dispose(): void;
  41674. }
  41675. }
  41676. declare module BABYLON {
  41677. /**
  41678. * Represents an XR input
  41679. */
  41680. export class WebXRController {
  41681. private scene;
  41682. /** The underlying input source for the controller */
  41683. inputSource: XRInputSource;
  41684. private parentContainer;
  41685. /**
  41686. * 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
  41687. */
  41688. grip?: AbstractMesh;
  41689. /**
  41690. * Pointer which can be used to select objects or attach a visible laser to
  41691. */
  41692. pointer: AbstractMesh;
  41693. /**
  41694. * Event that fires when the controller is removed/disposed
  41695. */
  41696. onDisposeObservable: Observable<{}>;
  41697. private _tmpMatrix;
  41698. private _tmpQuaternion;
  41699. private _tmpVector;
  41700. /**
  41701. * Creates the controller
  41702. * @see https://doc.babylonjs.com/how_to/webxr
  41703. * @param scene the scene which the controller should be associated to
  41704. * @param inputSource the underlying input source for the controller
  41705. * @param parentContainer parent that the controller meshes should be children of
  41706. */
  41707. constructor(scene: Scene,
  41708. /** The underlying input source for the controller */
  41709. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  41710. /**
  41711. * Updates the controller pose based on the given XRFrame
  41712. * @param xrFrame xr frame to update the pose with
  41713. * @param referenceSpace reference space to use
  41714. */
  41715. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  41716. /**
  41717. * Gets a world space ray coming from the controller
  41718. * @param result the resulting ray
  41719. */
  41720. getWorldPointerRayToRef(result: Ray): void;
  41721. /**
  41722. * Disposes of the object
  41723. */
  41724. dispose(): void;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * XR input used to track XR inputs such as controllers/rays
  41730. */
  41731. export class WebXRInput implements IDisposable {
  41732. /**
  41733. * Base experience the input listens to
  41734. */
  41735. baseExperience: WebXRExperienceHelper;
  41736. /**
  41737. * XR controllers being tracked
  41738. */
  41739. controllers: Array<WebXRController>;
  41740. private _frameObserver;
  41741. private _stateObserver;
  41742. /**
  41743. * Event when a controller has been connected/added
  41744. */
  41745. onControllerAddedObservable: Observable<WebXRController>;
  41746. /**
  41747. * Event when a controller has been removed/disconnected
  41748. */
  41749. onControllerRemovedObservable: Observable<WebXRController>;
  41750. /**
  41751. * Initializes the WebXRInput
  41752. * @param baseExperience experience helper which the input should be created for
  41753. */
  41754. constructor(
  41755. /**
  41756. * Base experience the input listens to
  41757. */
  41758. baseExperience: WebXRExperienceHelper);
  41759. private _onInputSourcesChange;
  41760. private _addAndRemoveControllers;
  41761. /**
  41762. * Disposes of the object
  41763. */
  41764. dispose(): void;
  41765. }
  41766. }
  41767. declare module BABYLON {
  41768. /**
  41769. * Enables teleportation
  41770. */
  41771. export class WebXRControllerTeleportation {
  41772. private _teleportationFillColor;
  41773. private _teleportationBorderColor;
  41774. private _tmpRay;
  41775. private _tmpVector;
  41776. /**
  41777. * Creates a WebXRControllerTeleportation
  41778. * @param input input manager to add teleportation to
  41779. * @param floorMeshes floormeshes which can be teleported to
  41780. */
  41781. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41782. }
  41783. }
  41784. declare module BABYLON {
  41785. /**
  41786. * Handles pointer input automatically for the pointer of XR controllers
  41787. */
  41788. export class WebXRControllerPointerSelection {
  41789. private static _idCounter;
  41790. private _tmpRay;
  41791. /**
  41792. * Creates a WebXRControllerPointerSelection
  41793. * @param input input manager to setup pointer selection
  41794. */
  41795. constructor(input: WebXRInput);
  41796. private _convertNormalToDirectionOfRay;
  41797. private _updatePointerDistance;
  41798. }
  41799. }
  41800. declare module BABYLON {
  41801. /**
  41802. * Class used to represent data loading progression
  41803. */
  41804. export class SceneLoaderProgressEvent {
  41805. /** defines if data length to load can be evaluated */
  41806. readonly lengthComputable: boolean;
  41807. /** defines the loaded data length */
  41808. readonly loaded: number;
  41809. /** defines the data length to load */
  41810. readonly total: number;
  41811. /**
  41812. * Create a new progress event
  41813. * @param lengthComputable defines if data length to load can be evaluated
  41814. * @param loaded defines the loaded data length
  41815. * @param total defines the data length to load
  41816. */
  41817. constructor(
  41818. /** defines if data length to load can be evaluated */
  41819. lengthComputable: boolean,
  41820. /** defines the loaded data length */
  41821. loaded: number,
  41822. /** defines the data length to load */
  41823. total: number);
  41824. /**
  41825. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41826. * @param event defines the source event
  41827. * @returns a new SceneLoaderProgressEvent
  41828. */
  41829. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41830. }
  41831. /**
  41832. * Interface used by SceneLoader plugins to define supported file extensions
  41833. */
  41834. export interface ISceneLoaderPluginExtensions {
  41835. /**
  41836. * Defines the list of supported extensions
  41837. */
  41838. [extension: string]: {
  41839. isBinary: boolean;
  41840. };
  41841. }
  41842. /**
  41843. * Interface used by SceneLoader plugin factory
  41844. */
  41845. export interface ISceneLoaderPluginFactory {
  41846. /**
  41847. * Defines the name of the factory
  41848. */
  41849. name: string;
  41850. /**
  41851. * Function called to create a new plugin
  41852. * @return the new plugin
  41853. */
  41854. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41855. /**
  41856. * Boolean indicating if the plugin can direct load specific data
  41857. */
  41858. canDirectLoad?: (data: string) => boolean;
  41859. }
  41860. /**
  41861. * Interface used to define a SceneLoader plugin
  41862. */
  41863. export interface ISceneLoaderPlugin {
  41864. /**
  41865. * The friendly name of this plugin.
  41866. */
  41867. name: string;
  41868. /**
  41869. * The file extensions supported by this plugin.
  41870. */
  41871. extensions: string | ISceneLoaderPluginExtensions;
  41872. /**
  41873. * Import meshes into a scene.
  41874. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41875. * @param scene The scene to import into
  41876. * @param data The data to import
  41877. * @param rootUrl The root url for scene and resources
  41878. * @param meshes The meshes array to import into
  41879. * @param particleSystems The particle systems array to import into
  41880. * @param skeletons The skeletons array to import into
  41881. * @param onError The callback when import fails
  41882. * @returns True if successful or false otherwise
  41883. */
  41884. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41885. /**
  41886. * Load into a scene.
  41887. * @param scene The scene to load into
  41888. * @param data The data to import
  41889. * @param rootUrl The root url for scene and resources
  41890. * @param onError The callback when import fails
  41891. * @returns true if successful or false otherwise
  41892. */
  41893. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41894. /**
  41895. * The callback that returns true if the data can be directly loaded.
  41896. */
  41897. canDirectLoad?: (data: string) => boolean;
  41898. /**
  41899. * The callback that allows custom handling of the root url based on the response url.
  41900. */
  41901. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41902. /**
  41903. * Load into an asset container.
  41904. * @param scene The scene to load into
  41905. * @param data The data to import
  41906. * @param rootUrl The root url for scene and resources
  41907. * @param onError The callback when import fails
  41908. * @returns The loaded asset container
  41909. */
  41910. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41911. }
  41912. /**
  41913. * Interface used to define an async SceneLoader plugin
  41914. */
  41915. export interface ISceneLoaderPluginAsync {
  41916. /**
  41917. * The friendly name of this plugin.
  41918. */
  41919. name: string;
  41920. /**
  41921. * The file extensions supported by this plugin.
  41922. */
  41923. extensions: string | ISceneLoaderPluginExtensions;
  41924. /**
  41925. * Import meshes into a scene.
  41926. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41927. * @param scene The scene to import into
  41928. * @param data The data to import
  41929. * @param rootUrl The root url for scene and resources
  41930. * @param onProgress The callback when the load progresses
  41931. * @param fileName Defines the name of the file to load
  41932. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41933. */
  41934. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41935. meshes: AbstractMesh[];
  41936. particleSystems: IParticleSystem[];
  41937. skeletons: Skeleton[];
  41938. animationGroups: AnimationGroup[];
  41939. }>;
  41940. /**
  41941. * Load into a scene.
  41942. * @param scene The scene to load into
  41943. * @param data The data to import
  41944. * @param rootUrl The root url for scene and resources
  41945. * @param onProgress The callback when the load progresses
  41946. * @param fileName Defines the name of the file to load
  41947. * @returns Nothing
  41948. */
  41949. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41950. /**
  41951. * The callback that returns true if the data can be directly loaded.
  41952. */
  41953. canDirectLoad?: (data: string) => boolean;
  41954. /**
  41955. * The callback that allows custom handling of the root url based on the response url.
  41956. */
  41957. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41958. /**
  41959. * Load into an asset container.
  41960. * @param scene The scene to load into
  41961. * @param data The data to import
  41962. * @param rootUrl The root url for scene and resources
  41963. * @param onProgress The callback when the load progresses
  41964. * @param fileName Defines the name of the file to load
  41965. * @returns The loaded asset container
  41966. */
  41967. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41968. }
  41969. /**
  41970. * Class used to load scene from various file formats using registered plugins
  41971. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41972. */
  41973. export class SceneLoader {
  41974. /**
  41975. * No logging while loading
  41976. */
  41977. static readonly NO_LOGGING: number;
  41978. /**
  41979. * Minimal logging while loading
  41980. */
  41981. static readonly MINIMAL_LOGGING: number;
  41982. /**
  41983. * Summary logging while loading
  41984. */
  41985. static readonly SUMMARY_LOGGING: number;
  41986. /**
  41987. * Detailled logging while loading
  41988. */
  41989. static readonly DETAILED_LOGGING: number;
  41990. /**
  41991. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41992. */
  41993. static ForceFullSceneLoadingForIncremental: boolean;
  41994. /**
  41995. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41996. */
  41997. static ShowLoadingScreen: boolean;
  41998. /**
  41999. * Defines the current logging level (while loading the scene)
  42000. * @ignorenaming
  42001. */
  42002. static loggingLevel: number;
  42003. /**
  42004. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42005. */
  42006. static CleanBoneMatrixWeights: boolean;
  42007. /**
  42008. * Event raised when a plugin is used to load a scene
  42009. */
  42010. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42011. private static _registeredPlugins;
  42012. private static _getDefaultPlugin;
  42013. private static _getPluginForExtension;
  42014. private static _getPluginForDirectLoad;
  42015. private static _getPluginForFilename;
  42016. private static _getDirectLoad;
  42017. private static _loadData;
  42018. private static _getFileInfo;
  42019. /**
  42020. * Gets a plugin that can load the given extension
  42021. * @param extension defines the extension to load
  42022. * @returns a plugin or null if none works
  42023. */
  42024. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42025. /**
  42026. * Gets a boolean indicating that the given extension can be loaded
  42027. * @param extension defines the extension to load
  42028. * @returns true if the extension is supported
  42029. */
  42030. static IsPluginForExtensionAvailable(extension: string): boolean;
  42031. /**
  42032. * Adds a new plugin to the list of registered plugins
  42033. * @param plugin defines the plugin to add
  42034. */
  42035. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42036. /**
  42037. * Import meshes into a scene
  42038. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42039. * @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)
  42040. * @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)
  42041. * @param scene the instance of BABYLON.Scene to append to
  42042. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42043. * @param onProgress a callback with a progress event for each file being loaded
  42044. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42045. * @param pluginExtension the extension used to determine the plugin
  42046. * @returns The loaded plugin
  42047. */
  42048. 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>;
  42049. /**
  42050. * Import meshes into a scene
  42051. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42052. * @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)
  42053. * @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)
  42054. * @param scene the instance of BABYLON.Scene to append to
  42055. * @param onProgress a callback with a progress event for each file being loaded
  42056. * @param pluginExtension the extension used to determine the plugin
  42057. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42058. */
  42059. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42060. meshes: AbstractMesh[];
  42061. particleSystems: IParticleSystem[];
  42062. skeletons: Skeleton[];
  42063. animationGroups: AnimationGroup[];
  42064. }>;
  42065. /**
  42066. * Load a scene
  42067. * @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)
  42068. * @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)
  42069. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42070. * @param onSuccess a callback with the scene when import succeeds
  42071. * @param onProgress a callback with a progress event for each file being loaded
  42072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42073. * @param pluginExtension the extension used to determine the plugin
  42074. * @returns The loaded plugin
  42075. */
  42076. 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>;
  42077. /**
  42078. * Load a scene
  42079. * @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)
  42080. * @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)
  42081. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42082. * @param onProgress a callback with a progress event for each file being loaded
  42083. * @param pluginExtension the extension used to determine the plugin
  42084. * @returns The loaded scene
  42085. */
  42086. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42087. /**
  42088. * Append a scene
  42089. * @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)
  42090. * @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)
  42091. * @param scene is the instance of BABYLON.Scene to append to
  42092. * @param onSuccess a callback with the scene when import succeeds
  42093. * @param onProgress a callback with a progress event for each file being loaded
  42094. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42095. * @param pluginExtension the extension used to determine the plugin
  42096. * @returns The loaded plugin
  42097. */
  42098. 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>;
  42099. /**
  42100. * Append a scene
  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 is the instance of BABYLON.Scene to append to
  42104. * @param onProgress a callback with a progress event for each file being loaded
  42105. * @param pluginExtension the extension used to determine the plugin
  42106. * @returns The given scene
  42107. */
  42108. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42109. /**
  42110. * Load a scene into an asset container
  42111. * @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)
  42112. * @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)
  42113. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42114. * @param onSuccess a callback with the scene when import succeeds
  42115. * @param onProgress a callback with a progress event for each file being loaded
  42116. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42117. * @param pluginExtension the extension used to determine the plugin
  42118. * @returns The loaded plugin
  42119. */
  42120. 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>;
  42121. /**
  42122. * Load a scene into an asset container
  42123. * @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)
  42124. * @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)
  42125. * @param scene is the instance of Scene to append to
  42126. * @param onProgress a callback with a progress event for each file being loaded
  42127. * @param pluginExtension the extension used to determine the plugin
  42128. * @returns The loaded asset container
  42129. */
  42130. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42131. }
  42132. }
  42133. declare module BABYLON {
  42134. /**
  42135. * Generic Controller
  42136. */
  42137. export class GenericController extends WebVRController {
  42138. /**
  42139. * Base Url for the controller model.
  42140. */
  42141. static readonly MODEL_BASE_URL: string;
  42142. /**
  42143. * File name for the controller model.
  42144. */
  42145. static readonly MODEL_FILENAME: string;
  42146. /**
  42147. * Creates a new GenericController from a gamepad
  42148. * @param vrGamepad the gamepad that the controller should be created from
  42149. */
  42150. constructor(vrGamepad: any);
  42151. /**
  42152. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42153. * @param scene scene in which to add meshes
  42154. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42155. */
  42156. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42157. /**
  42158. * Called once for each button that changed state since the last frame
  42159. * @param buttonIdx Which button index changed
  42160. * @param state New state of the button
  42161. * @param changes Which properties on the state changed since last frame
  42162. */
  42163. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42164. }
  42165. }
  42166. declare module BABYLON {
  42167. /**
  42168. * Defines the WindowsMotionController object that the state of the windows motion controller
  42169. */
  42170. export class WindowsMotionController extends WebVRController {
  42171. /**
  42172. * The base url used to load the left and right controller models
  42173. */
  42174. static MODEL_BASE_URL: string;
  42175. /**
  42176. * The name of the left controller model file
  42177. */
  42178. static MODEL_LEFT_FILENAME: string;
  42179. /**
  42180. * The name of the right controller model file
  42181. */
  42182. static MODEL_RIGHT_FILENAME: string;
  42183. /**
  42184. * The controller name prefix for this controller type
  42185. */
  42186. static readonly GAMEPAD_ID_PREFIX: string;
  42187. /**
  42188. * The controller id pattern for this controller type
  42189. */
  42190. private static readonly GAMEPAD_ID_PATTERN;
  42191. private _loadedMeshInfo;
  42192. private readonly _mapping;
  42193. /**
  42194. * Fired when the trackpad on this controller is clicked
  42195. */
  42196. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42197. /**
  42198. * Fired when the trackpad on this controller is modified
  42199. */
  42200. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42201. /**
  42202. * The current x and y values of this controller's trackpad
  42203. */
  42204. trackpad: StickValues;
  42205. /**
  42206. * Creates a new WindowsMotionController from a gamepad
  42207. * @param vrGamepad the gamepad that the controller should be created from
  42208. */
  42209. constructor(vrGamepad: any);
  42210. /**
  42211. * Fired when the trigger on this controller is modified
  42212. */
  42213. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42214. /**
  42215. * Fired when the menu button on this controller is modified
  42216. */
  42217. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42218. /**
  42219. * Fired when the grip button on this controller is modified
  42220. */
  42221. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42222. /**
  42223. * Fired when the thumbstick button on this controller is modified
  42224. */
  42225. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42226. /**
  42227. * Fired when the touchpad button on this controller is modified
  42228. */
  42229. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42230. /**
  42231. * Fired when the touchpad values on this controller are modified
  42232. */
  42233. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42234. private _updateTrackpad;
  42235. /**
  42236. * Called once per frame by the engine.
  42237. */
  42238. update(): void;
  42239. /**
  42240. * Called once for each button that changed state since the last frame
  42241. * @param buttonIdx Which button index changed
  42242. * @param state New state of the button
  42243. * @param changes Which properties on the state changed since last frame
  42244. */
  42245. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42246. /**
  42247. * Moves the buttons on the controller mesh based on their current state
  42248. * @param buttonName the name of the button to move
  42249. * @param buttonValue the value of the button which determines the buttons new position
  42250. */
  42251. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42252. /**
  42253. * Moves the axis on the controller mesh based on its current state
  42254. * @param axis the index of the axis
  42255. * @param axisValue the value of the axis which determines the meshes new position
  42256. * @hidden
  42257. */
  42258. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42259. /**
  42260. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42261. * @param scene scene in which to add meshes
  42262. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42263. */
  42264. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42265. /**
  42266. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42267. * can be transformed by button presses and axes values, based on this._mapping.
  42268. *
  42269. * @param scene scene in which the meshes exist
  42270. * @param meshes list of meshes that make up the controller model to process
  42271. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42272. */
  42273. private processModel;
  42274. private createMeshInfo;
  42275. /**
  42276. * Gets the ray of the controller in the direction the controller is pointing
  42277. * @param length the length the resulting ray should be
  42278. * @returns a ray in the direction the controller is pointing
  42279. */
  42280. getForwardRay(length?: number): Ray;
  42281. /**
  42282. * Disposes of the controller
  42283. */
  42284. dispose(): void;
  42285. }
  42286. }
  42287. declare module BABYLON {
  42288. /**
  42289. * Oculus Touch Controller
  42290. */
  42291. export class OculusTouchController extends WebVRController {
  42292. /**
  42293. * Base Url for the controller model.
  42294. */
  42295. static MODEL_BASE_URL: string;
  42296. /**
  42297. * File name for the left controller model.
  42298. */
  42299. static MODEL_LEFT_FILENAME: string;
  42300. /**
  42301. * File name for the right controller model.
  42302. */
  42303. static MODEL_RIGHT_FILENAME: string;
  42304. /**
  42305. * Base Url for the Quest controller model.
  42306. */
  42307. static QUEST_MODEL_BASE_URL: string;
  42308. /**
  42309. * @hidden
  42310. * If the controllers are running on a device that needs the updated Quest controller models
  42311. */
  42312. static _IsQuest: boolean;
  42313. /**
  42314. * Fired when the secondary trigger on this controller is modified
  42315. */
  42316. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42317. /**
  42318. * Fired when the thumb rest on this controller is modified
  42319. */
  42320. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42321. /**
  42322. * Creates a new OculusTouchController from a gamepad
  42323. * @param vrGamepad the gamepad that the controller should be created from
  42324. */
  42325. constructor(vrGamepad: any);
  42326. /**
  42327. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42328. * @param scene scene in which to add meshes
  42329. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42330. */
  42331. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42332. /**
  42333. * Fired when the A button on this controller is modified
  42334. */
  42335. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42336. /**
  42337. * Fired when the B button on this controller is modified
  42338. */
  42339. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42340. /**
  42341. * Fired when the X button on this controller is modified
  42342. */
  42343. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42344. /**
  42345. * Fired when the Y button on this controller is modified
  42346. */
  42347. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42348. /**
  42349. * Called once for each button that changed state since the last frame
  42350. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42351. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42352. * 2) secondary trigger (same)
  42353. * 3) A (right) X (left), touch, pressed = value
  42354. * 4) B / Y
  42355. * 5) thumb rest
  42356. * @param buttonIdx Which button index changed
  42357. * @param state New state of the button
  42358. * @param changes Which properties on the state changed since last frame
  42359. */
  42360. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42361. }
  42362. }
  42363. declare module BABYLON {
  42364. /**
  42365. * Vive Controller
  42366. */
  42367. export class ViveController extends WebVRController {
  42368. /**
  42369. * Base Url for the controller model.
  42370. */
  42371. static MODEL_BASE_URL: string;
  42372. /**
  42373. * File name for the controller model.
  42374. */
  42375. static MODEL_FILENAME: string;
  42376. /**
  42377. * Creates a new ViveController from a gamepad
  42378. * @param vrGamepad the gamepad that the controller should be created from
  42379. */
  42380. constructor(vrGamepad: any);
  42381. /**
  42382. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42383. * @param scene scene in which to add meshes
  42384. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42385. */
  42386. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42387. /**
  42388. * Fired when the left button on this controller is modified
  42389. */
  42390. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42391. /**
  42392. * Fired when the right button on this controller is modified
  42393. */
  42394. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42395. /**
  42396. * Fired when the menu button on this controller is modified
  42397. */
  42398. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42399. /**
  42400. * Called once for each button that changed state since the last frame
  42401. * Vive mapping:
  42402. * 0: touchpad
  42403. * 1: trigger
  42404. * 2: left AND right buttons
  42405. * 3: menu button
  42406. * @param buttonIdx Which button index changed
  42407. * @param state New state of the button
  42408. * @param changes Which properties on the state changed since last frame
  42409. */
  42410. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42411. }
  42412. }
  42413. declare module BABYLON {
  42414. /**
  42415. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  42416. */
  42417. export class WebXRControllerModelLoader {
  42418. /**
  42419. * Creates the WebXRControllerModelLoader
  42420. * @param input xr input that creates the controllers
  42421. */
  42422. constructor(input: WebXRInput);
  42423. }
  42424. }
  42425. declare module BABYLON {
  42426. /**
  42427. * Contains an array of blocks representing the octree
  42428. */
  42429. export interface IOctreeContainer<T> {
  42430. /**
  42431. * Blocks within the octree
  42432. */
  42433. blocks: Array<OctreeBlock<T>>;
  42434. }
  42435. /**
  42436. * Class used to store a cell in an octree
  42437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42438. */
  42439. export class OctreeBlock<T> {
  42440. /**
  42441. * Gets the content of the current block
  42442. */
  42443. entries: T[];
  42444. /**
  42445. * Gets the list of block children
  42446. */
  42447. blocks: Array<OctreeBlock<T>>;
  42448. private _depth;
  42449. private _maxDepth;
  42450. private _capacity;
  42451. private _minPoint;
  42452. private _maxPoint;
  42453. private _boundingVectors;
  42454. private _creationFunc;
  42455. /**
  42456. * Creates a new block
  42457. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42458. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42459. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42460. * @param depth defines the current depth of this block in the octree
  42461. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42462. * @param creationFunc defines a callback to call when an element is added to the block
  42463. */
  42464. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42465. /**
  42466. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42467. */
  42468. readonly capacity: number;
  42469. /**
  42470. * Gets the minimum vector (in world space) of the block's bounding box
  42471. */
  42472. readonly minPoint: Vector3;
  42473. /**
  42474. * Gets the maximum vector (in world space) of the block's bounding box
  42475. */
  42476. readonly maxPoint: Vector3;
  42477. /**
  42478. * Add a new element to this block
  42479. * @param entry defines the element to add
  42480. */
  42481. addEntry(entry: T): void;
  42482. /**
  42483. * Remove an element from this block
  42484. * @param entry defines the element to remove
  42485. */
  42486. removeEntry(entry: T): void;
  42487. /**
  42488. * Add an array of elements to this block
  42489. * @param entries defines the array of elements to add
  42490. */
  42491. addEntries(entries: T[]): void;
  42492. /**
  42493. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42494. * @param frustumPlanes defines the frustum planes to test
  42495. * @param selection defines the array to store current content if selection is positive
  42496. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42497. */
  42498. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42499. /**
  42500. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42501. * @param sphereCenter defines the bounding sphere center
  42502. * @param sphereRadius defines the bounding sphere radius
  42503. * @param selection defines the array to store current content if selection is positive
  42504. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42505. */
  42506. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42507. /**
  42508. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42509. * @param ray defines the ray to test with
  42510. * @param selection defines the array to store current content if selection is positive
  42511. */
  42512. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42513. /**
  42514. * Subdivide the content into child blocks (this block will then be empty)
  42515. */
  42516. createInnerBlocks(): void;
  42517. /**
  42518. * @hidden
  42519. */
  42520. 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;
  42521. }
  42522. }
  42523. declare module BABYLON {
  42524. /**
  42525. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42526. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42527. */
  42528. export class Octree<T> {
  42529. /** 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.) */
  42530. maxDepth: number;
  42531. /**
  42532. * Blocks within the octree containing objects
  42533. */
  42534. blocks: Array<OctreeBlock<T>>;
  42535. /**
  42536. * Content stored in the octree
  42537. */
  42538. dynamicContent: T[];
  42539. private _maxBlockCapacity;
  42540. private _selectionContent;
  42541. private _creationFunc;
  42542. /**
  42543. * Creates a octree
  42544. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42545. * @param creationFunc function to be used to instatiate the octree
  42546. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42547. * @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.)
  42548. */
  42549. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42550. /** 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.) */
  42551. maxDepth?: number);
  42552. /**
  42553. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42554. * @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);
  42555. * @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);
  42556. * @param entries meshes to be added to the octree blocks
  42557. */
  42558. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42559. /**
  42560. * Adds a mesh to the octree
  42561. * @param entry Mesh to add to the octree
  42562. */
  42563. addMesh(entry: T): void;
  42564. /**
  42565. * Remove an element from the octree
  42566. * @param entry defines the element to remove
  42567. */
  42568. removeMesh(entry: T): void;
  42569. /**
  42570. * Selects an array of meshes within the frustum
  42571. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42572. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42573. * @returns array of meshes within the frustum
  42574. */
  42575. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42576. /**
  42577. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42578. * @param sphereCenter defines the bounding sphere center
  42579. * @param sphereRadius defines the bounding sphere radius
  42580. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42581. * @returns an array of objects that intersect the sphere
  42582. */
  42583. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42584. /**
  42585. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42586. * @param ray defines the ray to test with
  42587. * @returns array of intersected objects
  42588. */
  42589. intersectsRay(ray: Ray): SmartArray<T>;
  42590. /**
  42591. * Adds a mesh into the octree block if it intersects the block
  42592. */
  42593. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42594. /**
  42595. * Adds a submesh into the octree block if it intersects the block
  42596. */
  42597. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42598. }
  42599. }
  42600. declare module BABYLON {
  42601. interface Scene {
  42602. /**
  42603. * @hidden
  42604. * Backing Filed
  42605. */
  42606. _selectionOctree: Octree<AbstractMesh>;
  42607. /**
  42608. * Gets the octree used to boost mesh selection (picking)
  42609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42610. */
  42611. selectionOctree: Octree<AbstractMesh>;
  42612. /**
  42613. * Creates or updates the octree used to boost selection (picking)
  42614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42615. * @param maxCapacity defines the maximum capacity per leaf
  42616. * @param maxDepth defines the maximum depth of the octree
  42617. * @returns an octree of AbstractMesh
  42618. */
  42619. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42620. }
  42621. interface AbstractMesh {
  42622. /**
  42623. * @hidden
  42624. * Backing Field
  42625. */
  42626. _submeshesOctree: Octree<SubMesh>;
  42627. /**
  42628. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42629. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42630. * @param maxCapacity defines the maximum size of each block (64 by default)
  42631. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42632. * @returns the new octree
  42633. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42634. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42635. */
  42636. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42637. }
  42638. /**
  42639. * Defines the octree scene component responsible to manage any octrees
  42640. * in a given scene.
  42641. */
  42642. export class OctreeSceneComponent {
  42643. /**
  42644. * The component name help to identify the component in the list of scene components.
  42645. */
  42646. readonly name: string;
  42647. /**
  42648. * The scene the component belongs to.
  42649. */
  42650. scene: Scene;
  42651. /**
  42652. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42653. */
  42654. readonly checksIsEnabled: boolean;
  42655. /**
  42656. * Creates a new instance of the component for the given scene
  42657. * @param scene Defines the scene to register the component in
  42658. */
  42659. constructor(scene: Scene);
  42660. /**
  42661. * Registers the component in a given scene
  42662. */
  42663. register(): void;
  42664. /**
  42665. * Return the list of active meshes
  42666. * @returns the list of active meshes
  42667. */
  42668. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42669. /**
  42670. * Return the list of active sub meshes
  42671. * @param mesh The mesh to get the candidates sub meshes from
  42672. * @returns the list of active sub meshes
  42673. */
  42674. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42675. private _tempRay;
  42676. /**
  42677. * Return the list of sub meshes intersecting with a given local ray
  42678. * @param mesh defines the mesh to find the submesh for
  42679. * @param localRay defines the ray in local space
  42680. * @returns the list of intersecting sub meshes
  42681. */
  42682. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42683. /**
  42684. * Return the list of sub meshes colliding with a collider
  42685. * @param mesh defines the mesh to find the submesh for
  42686. * @param collider defines the collider to evaluate the collision against
  42687. * @returns the list of colliding sub meshes
  42688. */
  42689. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42690. /**
  42691. * Rebuilds the elements related to this component in case of
  42692. * context lost for instance.
  42693. */
  42694. rebuild(): void;
  42695. /**
  42696. * Disposes the component and the associated ressources.
  42697. */
  42698. dispose(): void;
  42699. }
  42700. }
  42701. declare module BABYLON {
  42702. /**
  42703. * Renders a layer on top of an existing scene
  42704. */
  42705. export class UtilityLayerRenderer implements IDisposable {
  42706. /** the original scene that will be rendered on top of */
  42707. originalScene: Scene;
  42708. private _pointerCaptures;
  42709. private _lastPointerEvents;
  42710. private static _DefaultUtilityLayer;
  42711. private static _DefaultKeepDepthUtilityLayer;
  42712. private _sharedGizmoLight;
  42713. private _renderCamera;
  42714. /**
  42715. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42716. * @returns the camera that is used when rendering the utility layer
  42717. */
  42718. getRenderCamera(): Nullable<Camera>;
  42719. /**
  42720. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42721. * @param cam the camera that should be used when rendering the utility layer
  42722. */
  42723. setRenderCamera(cam: Nullable<Camera>): void;
  42724. /**
  42725. * @hidden
  42726. * Light which used by gizmos to get light shading
  42727. */
  42728. _getSharedGizmoLight(): HemisphericLight;
  42729. /**
  42730. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42731. */
  42732. pickUtilitySceneFirst: boolean;
  42733. /**
  42734. * 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)
  42735. */
  42736. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42737. /**
  42738. * 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)
  42739. */
  42740. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42741. /**
  42742. * The scene that is rendered on top of the original scene
  42743. */
  42744. utilityLayerScene: Scene;
  42745. /**
  42746. * If the utility layer should automatically be rendered on top of existing scene
  42747. */
  42748. shouldRender: boolean;
  42749. /**
  42750. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42751. */
  42752. onlyCheckPointerDownEvents: boolean;
  42753. /**
  42754. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42755. */
  42756. processAllEvents: boolean;
  42757. /**
  42758. * Observable raised when the pointer move from the utility layer scene to the main scene
  42759. */
  42760. onPointerOutObservable: Observable<number>;
  42761. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42762. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42763. private _afterRenderObserver;
  42764. private _sceneDisposeObserver;
  42765. private _originalPointerObserver;
  42766. /**
  42767. * Instantiates a UtilityLayerRenderer
  42768. * @param originalScene the original scene that will be rendered on top of
  42769. * @param handleEvents boolean indicating if the utility layer should handle events
  42770. */
  42771. constructor(
  42772. /** the original scene that will be rendered on top of */
  42773. originalScene: Scene, handleEvents?: boolean);
  42774. private _notifyObservers;
  42775. /**
  42776. * Renders the utility layers scene on top of the original scene
  42777. */
  42778. render(): void;
  42779. /**
  42780. * Disposes of the renderer
  42781. */
  42782. dispose(): void;
  42783. private _updateCamera;
  42784. }
  42785. }
  42786. declare module BABYLON {
  42787. /**
  42788. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42789. */
  42790. export class Gizmo implements IDisposable {
  42791. /** The utility layer the gizmo will be added to */
  42792. gizmoLayer: UtilityLayerRenderer;
  42793. /**
  42794. * The root mesh of the gizmo
  42795. */
  42796. _rootMesh: Mesh;
  42797. private _attachedMesh;
  42798. /**
  42799. * Ratio for the scale of the gizmo (Default: 1)
  42800. */
  42801. scaleRatio: number;
  42802. /**
  42803. * If a custom mesh has been set (Default: false)
  42804. */
  42805. protected _customMeshSet: boolean;
  42806. /**
  42807. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42808. * * When set, interactions will be enabled
  42809. */
  42810. attachedMesh: Nullable<AbstractMesh>;
  42811. /**
  42812. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42813. * @param mesh The mesh to replace the default mesh of the gizmo
  42814. */
  42815. setCustomMesh(mesh: Mesh): void;
  42816. /**
  42817. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42818. */
  42819. updateGizmoRotationToMatchAttachedMesh: boolean;
  42820. /**
  42821. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42822. */
  42823. updateGizmoPositionToMatchAttachedMesh: boolean;
  42824. /**
  42825. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42826. */
  42827. updateScale: boolean;
  42828. protected _interactionsEnabled: boolean;
  42829. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42830. private _beforeRenderObserver;
  42831. private _tempVector;
  42832. /**
  42833. * Creates a gizmo
  42834. * @param gizmoLayer The utility layer the gizmo will be added to
  42835. */
  42836. constructor(
  42837. /** The utility layer the gizmo will be added to */
  42838. gizmoLayer?: UtilityLayerRenderer);
  42839. /**
  42840. * Updates the gizmo to match the attached mesh's position/rotation
  42841. */
  42842. protected _update(): void;
  42843. /**
  42844. * Disposes of the gizmo
  42845. */
  42846. dispose(): void;
  42847. }
  42848. }
  42849. declare module BABYLON {
  42850. /**
  42851. * Single plane drag gizmo
  42852. */
  42853. export class PlaneDragGizmo extends Gizmo {
  42854. /**
  42855. * Drag behavior responsible for the gizmos dragging interactions
  42856. */
  42857. dragBehavior: PointerDragBehavior;
  42858. private _pointerObserver;
  42859. /**
  42860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42861. */
  42862. snapDistance: number;
  42863. /**
  42864. * Event that fires each time the gizmo snaps to a new location.
  42865. * * snapDistance is the the change in distance
  42866. */
  42867. onSnapObservable: Observable<{
  42868. snapDistance: number;
  42869. }>;
  42870. private _plane;
  42871. private _coloredMaterial;
  42872. private _hoverMaterial;
  42873. private _isEnabled;
  42874. private _parent;
  42875. /** @hidden */
  42876. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42877. /** @hidden */
  42878. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42879. /**
  42880. * Creates a PlaneDragGizmo
  42881. * @param gizmoLayer The utility layer the gizmo will be added to
  42882. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42883. * @param color The color of the gizmo
  42884. */
  42885. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42886. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42887. /**
  42888. * If the gizmo is enabled
  42889. */
  42890. isEnabled: boolean;
  42891. /**
  42892. * Disposes of the gizmo
  42893. */
  42894. dispose(): void;
  42895. }
  42896. }
  42897. declare module BABYLON {
  42898. /**
  42899. * Gizmo that enables dragging a mesh along 3 axis
  42900. */
  42901. export class PositionGizmo extends Gizmo {
  42902. /**
  42903. * Internal gizmo used for interactions on the x axis
  42904. */
  42905. xGizmo: AxisDragGizmo;
  42906. /**
  42907. * Internal gizmo used for interactions on the y axis
  42908. */
  42909. yGizmo: AxisDragGizmo;
  42910. /**
  42911. * Internal gizmo used for interactions on the z axis
  42912. */
  42913. zGizmo: AxisDragGizmo;
  42914. /**
  42915. * Internal gizmo used for interactions on the yz plane
  42916. */
  42917. xPlaneGizmo: PlaneDragGizmo;
  42918. /**
  42919. * Internal gizmo used for interactions on the xz plane
  42920. */
  42921. yPlaneGizmo: PlaneDragGizmo;
  42922. /**
  42923. * Internal gizmo used for interactions on the xy plane
  42924. */
  42925. zPlaneGizmo: PlaneDragGizmo;
  42926. /**
  42927. * private variables
  42928. */
  42929. private _meshAttached;
  42930. private _updateGizmoRotationToMatchAttachedMesh;
  42931. private _snapDistance;
  42932. private _scaleRatio;
  42933. /** Fires an event when any of it's sub gizmos are dragged */
  42934. onDragStartObservable: Observable<unknown>;
  42935. /** Fires an event when any of it's sub gizmos are released from dragging */
  42936. onDragEndObservable: Observable<unknown>;
  42937. /**
  42938. * If set to true, planar drag is enabled
  42939. */
  42940. private _planarGizmoEnabled;
  42941. attachedMesh: Nullable<AbstractMesh>;
  42942. /**
  42943. * Creates a PositionGizmo
  42944. * @param gizmoLayer The utility layer the gizmo will be added to
  42945. */
  42946. constructor(gizmoLayer?: UtilityLayerRenderer);
  42947. /**
  42948. * If the planar drag gizmo is enabled
  42949. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42950. */
  42951. planarGizmoEnabled: boolean;
  42952. updateGizmoRotationToMatchAttachedMesh: boolean;
  42953. /**
  42954. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42955. */
  42956. snapDistance: number;
  42957. /**
  42958. * Ratio for the scale of the gizmo (Default: 1)
  42959. */
  42960. scaleRatio: number;
  42961. /**
  42962. * Disposes of the gizmo
  42963. */
  42964. dispose(): void;
  42965. /**
  42966. * CustomMeshes are not supported by this gizmo
  42967. * @param mesh The mesh to replace the default mesh of the gizmo
  42968. */
  42969. setCustomMesh(mesh: Mesh): void;
  42970. }
  42971. }
  42972. declare module BABYLON {
  42973. /**
  42974. * Single axis drag gizmo
  42975. */
  42976. export class AxisDragGizmo extends Gizmo {
  42977. /**
  42978. * Drag behavior responsible for the gizmos dragging interactions
  42979. */
  42980. dragBehavior: PointerDragBehavior;
  42981. private _pointerObserver;
  42982. /**
  42983. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42984. */
  42985. snapDistance: number;
  42986. /**
  42987. * Event that fires each time the gizmo snaps to a new location.
  42988. * * snapDistance is the the change in distance
  42989. */
  42990. onSnapObservable: Observable<{
  42991. snapDistance: number;
  42992. }>;
  42993. private _isEnabled;
  42994. private _parent;
  42995. private _arrow;
  42996. private _coloredMaterial;
  42997. private _hoverMaterial;
  42998. /** @hidden */
  42999. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43000. /** @hidden */
  43001. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43002. /**
  43003. * Creates an AxisDragGizmo
  43004. * @param gizmoLayer The utility layer the gizmo will be added to
  43005. * @param dragAxis The axis which the gizmo will be able to drag on
  43006. * @param color The color of the gizmo
  43007. */
  43008. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43009. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43010. /**
  43011. * If the gizmo is enabled
  43012. */
  43013. isEnabled: boolean;
  43014. /**
  43015. * Disposes of the gizmo
  43016. */
  43017. dispose(): void;
  43018. }
  43019. }
  43020. declare module BABYLON.Debug {
  43021. /**
  43022. * The Axes viewer will show 3 axes in a specific point in space
  43023. */
  43024. export class AxesViewer {
  43025. private _xAxis;
  43026. private _yAxis;
  43027. private _zAxis;
  43028. private _scaleLinesFactor;
  43029. private _instanced;
  43030. /**
  43031. * Gets the hosting scene
  43032. */
  43033. scene: Scene;
  43034. /**
  43035. * Gets or sets a number used to scale line length
  43036. */
  43037. scaleLines: number;
  43038. /** Gets the node hierarchy used to render x-axis */
  43039. readonly xAxis: TransformNode;
  43040. /** Gets the node hierarchy used to render y-axis */
  43041. readonly yAxis: TransformNode;
  43042. /** Gets the node hierarchy used to render z-axis */
  43043. readonly zAxis: TransformNode;
  43044. /**
  43045. * Creates a new AxesViewer
  43046. * @param scene defines the hosting scene
  43047. * @param scaleLines defines a number used to scale line length (1 by default)
  43048. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  43049. * @param xAxis defines the node hierarchy used to render the x-axis
  43050. * @param yAxis defines the node hierarchy used to render the y-axis
  43051. * @param zAxis defines the node hierarchy used to render the z-axis
  43052. */
  43053. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  43054. /**
  43055. * Force the viewer to update
  43056. * @param position defines the position of the viewer
  43057. * @param xaxis defines the x axis of the viewer
  43058. * @param yaxis defines the y axis of the viewer
  43059. * @param zaxis defines the z axis of the viewer
  43060. */
  43061. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  43062. /**
  43063. * Creates an instance of this axes viewer.
  43064. * @returns a new axes viewer with instanced meshes
  43065. */
  43066. createInstance(): AxesViewer;
  43067. /** Releases resources */
  43068. dispose(): void;
  43069. private static _SetRenderingGroupId;
  43070. }
  43071. }
  43072. declare module BABYLON.Debug {
  43073. /**
  43074. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  43075. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  43076. */
  43077. export class BoneAxesViewer extends AxesViewer {
  43078. /**
  43079. * Gets or sets the target mesh where to display the axes viewer
  43080. */
  43081. mesh: Nullable<Mesh>;
  43082. /**
  43083. * Gets or sets the target bone where to display the axes viewer
  43084. */
  43085. bone: Nullable<Bone>;
  43086. /** Gets current position */
  43087. pos: Vector3;
  43088. /** Gets direction of X axis */
  43089. xaxis: Vector3;
  43090. /** Gets direction of Y axis */
  43091. yaxis: Vector3;
  43092. /** Gets direction of Z axis */
  43093. zaxis: Vector3;
  43094. /**
  43095. * Creates a new BoneAxesViewer
  43096. * @param scene defines the hosting scene
  43097. * @param bone defines the target bone
  43098. * @param mesh defines the target mesh
  43099. * @param scaleLines defines a scaling factor for line length (1 by default)
  43100. */
  43101. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  43102. /**
  43103. * Force the viewer to update
  43104. */
  43105. update(): void;
  43106. /** Releases resources */
  43107. dispose(): void;
  43108. }
  43109. }
  43110. declare module BABYLON {
  43111. /**
  43112. * Interface used to define scene explorer extensibility option
  43113. */
  43114. export interface IExplorerExtensibilityOption {
  43115. /**
  43116. * Define the option label
  43117. */
  43118. label: string;
  43119. /**
  43120. * Defines the action to execute on click
  43121. */
  43122. action: (entity: any) => void;
  43123. }
  43124. /**
  43125. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43126. */
  43127. export interface IExplorerExtensibilityGroup {
  43128. /**
  43129. * Defines a predicate to test if a given type mut be extended
  43130. */
  43131. predicate: (entity: any) => boolean;
  43132. /**
  43133. * Gets the list of options added to a type
  43134. */
  43135. entries: IExplorerExtensibilityOption[];
  43136. }
  43137. /**
  43138. * Interface used to define the options to use to create the Inspector
  43139. */
  43140. export interface IInspectorOptions {
  43141. /**
  43142. * Display in overlay mode (default: false)
  43143. */
  43144. overlay?: boolean;
  43145. /**
  43146. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43147. */
  43148. globalRoot?: HTMLElement;
  43149. /**
  43150. * Display the Scene explorer
  43151. */
  43152. showExplorer?: boolean;
  43153. /**
  43154. * Display the property inspector
  43155. */
  43156. showInspector?: boolean;
  43157. /**
  43158. * Display in embed mode (both panes on the right)
  43159. */
  43160. embedMode?: boolean;
  43161. /**
  43162. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43163. */
  43164. handleResize?: boolean;
  43165. /**
  43166. * Allow the panes to popup (default: true)
  43167. */
  43168. enablePopup?: boolean;
  43169. /**
  43170. * Allow the panes to be closed by users (default: true)
  43171. */
  43172. enableClose?: boolean;
  43173. /**
  43174. * Optional list of extensibility entries
  43175. */
  43176. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43177. /**
  43178. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43179. */
  43180. inspectorURL?: string;
  43181. }
  43182. interface Scene {
  43183. /**
  43184. * @hidden
  43185. * Backing field
  43186. */
  43187. _debugLayer: DebugLayer;
  43188. /**
  43189. * Gets the debug layer (aka Inspector) associated with the scene
  43190. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43191. */
  43192. debugLayer: DebugLayer;
  43193. }
  43194. /**
  43195. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43196. * what is happening in your scene
  43197. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43198. */
  43199. export class DebugLayer {
  43200. /**
  43201. * Define the url to get the inspector script from.
  43202. * By default it uses the babylonjs CDN.
  43203. * @ignoreNaming
  43204. */
  43205. static InspectorURL: string;
  43206. private _scene;
  43207. private BJSINSPECTOR;
  43208. private _onPropertyChangedObservable?;
  43209. /**
  43210. * Observable triggered when a property is changed through the inspector.
  43211. */
  43212. readonly onPropertyChangedObservable: any;
  43213. /**
  43214. * Instantiates a new debug layer.
  43215. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43216. * what is happening in your scene
  43217. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43218. * @param scene Defines the scene to inspect
  43219. */
  43220. constructor(scene: Scene);
  43221. /** Creates the inspector window. */
  43222. private _createInspector;
  43223. /**
  43224. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43225. * @param entity defines the entity to select
  43226. * @param lineContainerTitle defines the specific block to highlight
  43227. */
  43228. select(entity: any, lineContainerTitle?: string): void;
  43229. /** Get the inspector from bundle or global */
  43230. private _getGlobalInspector;
  43231. /**
  43232. * Get if the inspector is visible or not.
  43233. * @returns true if visible otherwise, false
  43234. */
  43235. isVisible(): boolean;
  43236. /**
  43237. * Hide the inspector and close its window.
  43238. */
  43239. hide(): void;
  43240. /**
  43241. * Launch the debugLayer.
  43242. * @param config Define the configuration of the inspector
  43243. * @return a promise fulfilled when the debug layer is visible
  43244. */
  43245. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43246. }
  43247. }
  43248. declare module BABYLON {
  43249. /**
  43250. * Class containing static functions to help procedurally build meshes
  43251. */
  43252. export class BoxBuilder {
  43253. /**
  43254. * Creates a box mesh
  43255. * * The parameter `size` sets the size (float) of each box side (default 1)
  43256. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43257. * * 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)
  43258. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43259. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43260. * * 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
  43261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43262. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43263. * @param name defines the name of the mesh
  43264. * @param options defines the options used to create the mesh
  43265. * @param scene defines the hosting scene
  43266. * @returns the box mesh
  43267. */
  43268. static CreateBox(name: string, options: {
  43269. size?: number;
  43270. width?: number;
  43271. height?: number;
  43272. depth?: number;
  43273. faceUV?: Vector4[];
  43274. faceColors?: Color4[];
  43275. sideOrientation?: number;
  43276. frontUVs?: Vector4;
  43277. backUVs?: Vector4;
  43278. wrap?: boolean;
  43279. topBaseAt?: number;
  43280. bottomBaseAt?: number;
  43281. updatable?: boolean;
  43282. }, scene?: Nullable<Scene>): Mesh;
  43283. }
  43284. }
  43285. declare module BABYLON {
  43286. /**
  43287. * Class containing static functions to help procedurally build meshes
  43288. */
  43289. export class SphereBuilder {
  43290. /**
  43291. * Creates a sphere mesh
  43292. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43293. * * 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`)
  43294. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43295. * * 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
  43296. * * 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)
  43297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43298. * * 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
  43299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43300. * @param name defines the name of the mesh
  43301. * @param options defines the options used to create the mesh
  43302. * @param scene defines the hosting scene
  43303. * @returns the sphere mesh
  43304. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43305. */
  43306. static CreateSphere(name: string, options: {
  43307. segments?: number;
  43308. diameter?: number;
  43309. diameterX?: number;
  43310. diameterY?: number;
  43311. diameterZ?: number;
  43312. arc?: number;
  43313. slice?: number;
  43314. sideOrientation?: number;
  43315. frontUVs?: Vector4;
  43316. backUVs?: Vector4;
  43317. updatable?: boolean;
  43318. }, scene?: Nullable<Scene>): Mesh;
  43319. }
  43320. }
  43321. declare module BABYLON.Debug {
  43322. /**
  43323. * Used to show the physics impostor around the specific mesh
  43324. */
  43325. export class PhysicsViewer {
  43326. /** @hidden */
  43327. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43328. /** @hidden */
  43329. protected _meshes: Array<Nullable<AbstractMesh>>;
  43330. /** @hidden */
  43331. protected _scene: Nullable<Scene>;
  43332. /** @hidden */
  43333. protected _numMeshes: number;
  43334. /** @hidden */
  43335. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43336. private _renderFunction;
  43337. private _utilityLayer;
  43338. private _debugBoxMesh;
  43339. private _debugSphereMesh;
  43340. private _debugCylinderMesh;
  43341. private _debugMaterial;
  43342. private _debugMeshMeshes;
  43343. /**
  43344. * Creates a new PhysicsViewer
  43345. * @param scene defines the hosting scene
  43346. */
  43347. constructor(scene: Scene);
  43348. /** @hidden */
  43349. protected _updateDebugMeshes(): void;
  43350. /**
  43351. * Renders a specified physic impostor
  43352. * @param impostor defines the impostor to render
  43353. * @param targetMesh defines the mesh represented by the impostor
  43354. * @returns the new debug mesh used to render the impostor
  43355. */
  43356. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43357. /**
  43358. * Hides a specified physic impostor
  43359. * @param impostor defines the impostor to hide
  43360. */
  43361. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43362. private _getDebugMaterial;
  43363. private _getDebugBoxMesh;
  43364. private _getDebugSphereMesh;
  43365. private _getDebugCylinderMesh;
  43366. private _getDebugMeshMesh;
  43367. private _getDebugMesh;
  43368. /** Releases all resources */
  43369. dispose(): void;
  43370. }
  43371. }
  43372. declare module BABYLON {
  43373. /**
  43374. * Class containing static functions to help procedurally build meshes
  43375. */
  43376. export class LinesBuilder {
  43377. /**
  43378. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43379. * * 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
  43380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43381. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43382. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43383. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43384. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43385. * * 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
  43386. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43389. * @param name defines the name of the new line system
  43390. * @param options defines the options used to create the line system
  43391. * @param scene defines the hosting scene
  43392. * @returns a new line system mesh
  43393. */
  43394. static CreateLineSystem(name: string, options: {
  43395. lines: Vector3[][];
  43396. updatable?: boolean;
  43397. instance?: Nullable<LinesMesh>;
  43398. colors?: Nullable<Color4[][]>;
  43399. useVertexAlpha?: boolean;
  43400. }, scene: Nullable<Scene>): LinesMesh;
  43401. /**
  43402. * Creates a line mesh
  43403. * 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
  43404. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43405. * * The parameter `points` is an array successive Vector3
  43406. * * 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
  43407. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43408. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43409. * * When updating an instance, remember that only point positions can change, not the number of points
  43410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43412. * @param name defines the name of the new line system
  43413. * @param options defines the options used to create the line system
  43414. * @param scene defines the hosting scene
  43415. * @returns a new line mesh
  43416. */
  43417. static CreateLines(name: string, options: {
  43418. points: Vector3[];
  43419. updatable?: boolean;
  43420. instance?: Nullable<LinesMesh>;
  43421. colors?: Color4[];
  43422. useVertexAlpha?: boolean;
  43423. }, scene?: Nullable<Scene>): LinesMesh;
  43424. /**
  43425. * Creates a dashed line mesh
  43426. * * 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
  43427. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43428. * * The parameter `points` is an array successive Vector3
  43429. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43430. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43431. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43432. * * 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
  43433. * * When updating an instance, remember that only point positions can change, not the number of points
  43434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43435. * @param name defines the name of the mesh
  43436. * @param options defines the options used to create the mesh
  43437. * @param scene defines the hosting scene
  43438. * @returns the dashed line mesh
  43439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43440. */
  43441. static CreateDashedLines(name: string, options: {
  43442. points: Vector3[];
  43443. dashSize?: number;
  43444. gapSize?: number;
  43445. dashNb?: number;
  43446. updatable?: boolean;
  43447. instance?: LinesMesh;
  43448. }, scene?: Nullable<Scene>): LinesMesh;
  43449. }
  43450. }
  43451. declare module BABYLON {
  43452. /**
  43453. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43454. * in order to better appreciate the issue one might have.
  43455. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43456. */
  43457. export class RayHelper {
  43458. /**
  43459. * Defines the ray we are currently tryin to visualize.
  43460. */
  43461. ray: Nullable<Ray>;
  43462. private _renderPoints;
  43463. private _renderLine;
  43464. private _renderFunction;
  43465. private _scene;
  43466. private _updateToMeshFunction;
  43467. private _attachedToMesh;
  43468. private _meshSpaceDirection;
  43469. private _meshSpaceOrigin;
  43470. /**
  43471. * Helper function to create a colored helper in a scene in one line.
  43472. * @param ray Defines the ray we are currently tryin to visualize
  43473. * @param scene Defines the scene the ray is used in
  43474. * @param color Defines the color we want to see the ray in
  43475. * @returns The newly created ray helper.
  43476. */
  43477. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43478. /**
  43479. * Instantiate a new ray helper.
  43480. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43481. * in order to better appreciate the issue one might have.
  43482. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43483. * @param ray Defines the ray we are currently tryin to visualize
  43484. */
  43485. constructor(ray: Ray);
  43486. /**
  43487. * Shows the ray we are willing to debug.
  43488. * @param scene Defines the scene the ray needs to be rendered in
  43489. * @param color Defines the color the ray needs to be rendered in
  43490. */
  43491. show(scene: Scene, color?: Color3): void;
  43492. /**
  43493. * Hides the ray we are debugging.
  43494. */
  43495. hide(): void;
  43496. private _render;
  43497. /**
  43498. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43499. * @param mesh Defines the mesh we want the helper attached to
  43500. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43501. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43502. * @param length Defines the length of the ray
  43503. */
  43504. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43505. /**
  43506. * Detach the ray helper from the mesh it has previously been attached to.
  43507. */
  43508. detachFromMesh(): void;
  43509. private _updateToMesh;
  43510. /**
  43511. * Dispose the helper and release its associated resources.
  43512. */
  43513. dispose(): void;
  43514. }
  43515. }
  43516. declare module BABYLON.Debug {
  43517. /**
  43518. * Class used to render a debug view of a given skeleton
  43519. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43520. */
  43521. export class SkeletonViewer {
  43522. /** defines the skeleton to render */
  43523. skeleton: Skeleton;
  43524. /** defines the mesh attached to the skeleton */
  43525. mesh: AbstractMesh;
  43526. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43527. autoUpdateBonesMatrices: boolean;
  43528. /** defines the rendering group id to use with the viewer */
  43529. renderingGroupId: number;
  43530. /** Gets or sets the color used to render the skeleton */
  43531. color: Color3;
  43532. private _scene;
  43533. private _debugLines;
  43534. private _debugMesh;
  43535. private _isEnabled;
  43536. private _renderFunction;
  43537. private _utilityLayer;
  43538. /**
  43539. * Returns the mesh used to render the bones
  43540. */
  43541. readonly debugMesh: Nullable<LinesMesh>;
  43542. /**
  43543. * Creates a new SkeletonViewer
  43544. * @param skeleton defines the skeleton to render
  43545. * @param mesh defines the mesh attached to the skeleton
  43546. * @param scene defines the hosting scene
  43547. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43548. * @param renderingGroupId defines the rendering group id to use with the viewer
  43549. */
  43550. constructor(
  43551. /** defines the skeleton to render */
  43552. skeleton: Skeleton,
  43553. /** defines the mesh attached to the skeleton */
  43554. mesh: AbstractMesh, scene: Scene,
  43555. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43556. autoUpdateBonesMatrices?: boolean,
  43557. /** defines the rendering group id to use with the viewer */
  43558. renderingGroupId?: number);
  43559. /** Gets or sets a boolean indicating if the viewer is enabled */
  43560. isEnabled: boolean;
  43561. private _getBonePosition;
  43562. private _getLinesForBonesWithLength;
  43563. private _getLinesForBonesNoLength;
  43564. /** Update the viewer to sync with current skeleton state */
  43565. update(): void;
  43566. /** Release associated resources */
  43567. dispose(): void;
  43568. }
  43569. }
  43570. declare module BABYLON {
  43571. /**
  43572. * Options to create the null engine
  43573. */
  43574. export class NullEngineOptions {
  43575. /**
  43576. * Render width (Default: 512)
  43577. */
  43578. renderWidth: number;
  43579. /**
  43580. * Render height (Default: 256)
  43581. */
  43582. renderHeight: number;
  43583. /**
  43584. * Texture size (Default: 512)
  43585. */
  43586. textureSize: number;
  43587. /**
  43588. * If delta time between frames should be constant
  43589. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43590. */
  43591. deterministicLockstep: boolean;
  43592. /**
  43593. * Maximum about of steps between frames (Default: 4)
  43594. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43595. */
  43596. lockstepMaxSteps: number;
  43597. }
  43598. /**
  43599. * The null engine class provides support for headless version of babylon.js.
  43600. * This can be used in server side scenario or for testing purposes
  43601. */
  43602. export class NullEngine extends Engine {
  43603. private _options;
  43604. /**
  43605. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  43606. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43607. * @returns true if engine is in deterministic lock step mode
  43608. */
  43609. isDeterministicLockStep(): boolean;
  43610. /**
  43611. * Gets the max steps when engine is running in deterministic lock step
  43612. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43613. * @returns the max steps
  43614. */
  43615. getLockstepMaxSteps(): number;
  43616. /**
  43617. * Gets the current hardware scaling level.
  43618. * By default the hardware scaling level is computed from the window device ratio.
  43619. * 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.
  43620. * @returns a number indicating the current hardware scaling level
  43621. */
  43622. getHardwareScalingLevel(): number;
  43623. constructor(options?: NullEngineOptions);
  43624. /**
  43625. * Creates a vertex buffer
  43626. * @param vertices the data for the vertex buffer
  43627. * @returns the new WebGL static buffer
  43628. */
  43629. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43630. /**
  43631. * Creates a new index buffer
  43632. * @param indices defines the content of the index buffer
  43633. * @param updatable defines if the index buffer must be updatable
  43634. * @returns a new webGL buffer
  43635. */
  43636. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43637. /**
  43638. * Clear the current render buffer or the current render target (if any is set up)
  43639. * @param color defines the color to use
  43640. * @param backBuffer defines if the back buffer must be cleared
  43641. * @param depth defines if the depth buffer must be cleared
  43642. * @param stencil defines if the stencil buffer must be cleared
  43643. */
  43644. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43645. /**
  43646. * Gets the current render width
  43647. * @param useScreen defines if screen size must be used (or the current render target if any)
  43648. * @returns a number defining the current render width
  43649. */
  43650. getRenderWidth(useScreen?: boolean): number;
  43651. /**
  43652. * Gets the current render height
  43653. * @param useScreen defines if screen size must be used (or the current render target if any)
  43654. * @returns a number defining the current render height
  43655. */
  43656. getRenderHeight(useScreen?: boolean): number;
  43657. /**
  43658. * Set the WebGL's viewport
  43659. * @param viewport defines the viewport element to be used
  43660. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  43661. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  43662. */
  43663. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  43664. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43665. /**
  43666. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  43667. * @param pipelineContext defines the pipeline context to use
  43668. * @param uniformsNames defines the list of uniform names
  43669. * @returns an array of webGL uniform locations
  43670. */
  43671. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43672. /**
  43673. * Gets the lsit of active attributes for a given webGL program
  43674. * @param pipelineContext defines the pipeline context to use
  43675. * @param attributesNames defines the list of attribute names to get
  43676. * @returns an array of indices indicating the offset of each attribute
  43677. */
  43678. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43679. /**
  43680. * Binds an effect to the webGL context
  43681. * @param effect defines the effect to bind
  43682. */
  43683. bindSamplers(effect: Effect): void;
  43684. /**
  43685. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  43686. * @param effect defines the effect to activate
  43687. */
  43688. enableEffect(effect: Effect): void;
  43689. /**
  43690. * Set various states to the webGL context
  43691. * @param culling defines backface culling state
  43692. * @param zOffset defines the value to apply to zOffset (0 by default)
  43693. * @param force defines if states must be applied even if cache is up to date
  43694. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  43695. */
  43696. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43697. /**
  43698. * Set the value of an uniform to an array of int32
  43699. * @param uniform defines the webGL uniform location where to store the value
  43700. * @param array defines the array of int32 to store
  43701. */
  43702. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43703. /**
  43704. * Set the value of an uniform to an array of int32 (stored as vec2)
  43705. * @param uniform defines the webGL uniform location where to store the value
  43706. * @param array defines the array of int32 to store
  43707. */
  43708. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43709. /**
  43710. * Set the value of an uniform to an array of int32 (stored as vec3)
  43711. * @param uniform defines the webGL uniform location where to store the value
  43712. * @param array defines the array of int32 to store
  43713. */
  43714. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43715. /**
  43716. * Set the value of an uniform to an array of int32 (stored as vec4)
  43717. * @param uniform defines the webGL uniform location where to store the value
  43718. * @param array defines the array of int32 to store
  43719. */
  43720. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43721. /**
  43722. * Set the value of an uniform to an array of float32
  43723. * @param uniform defines the webGL uniform location where to store the value
  43724. * @param array defines the array of float32 to store
  43725. */
  43726. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43727. /**
  43728. * Set the value of an uniform to an array of float32 (stored as vec2)
  43729. * @param uniform defines the webGL uniform location where to store the value
  43730. * @param array defines the array of float32 to store
  43731. */
  43732. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43733. /**
  43734. * Set the value of an uniform to an array of float32 (stored as vec3)
  43735. * @param uniform defines the webGL uniform location where to store the value
  43736. * @param array defines the array of float32 to store
  43737. */
  43738. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43739. /**
  43740. * Set the value of an uniform to an array of float32 (stored as vec4)
  43741. * @param uniform defines the webGL uniform location where to store the value
  43742. * @param array defines the array of float32 to store
  43743. */
  43744. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43745. /**
  43746. * Set the value of an uniform to an array of number
  43747. * @param uniform defines the webGL uniform location where to store the value
  43748. * @param array defines the array of number to store
  43749. */
  43750. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43751. /**
  43752. * Set the value of an uniform to an array of number (stored as vec2)
  43753. * @param uniform defines the webGL uniform location where to store the value
  43754. * @param array defines the array of number to store
  43755. */
  43756. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43757. /**
  43758. * Set the value of an uniform to an array of number (stored as vec3)
  43759. * @param uniform defines the webGL uniform location where to store the value
  43760. * @param array defines the array of number to store
  43761. */
  43762. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43763. /**
  43764. * Set the value of an uniform to an array of number (stored as vec4)
  43765. * @param uniform defines the webGL uniform location where to store the value
  43766. * @param array defines the array of number to store
  43767. */
  43768. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43769. /**
  43770. * Set the value of an uniform to an array of float32 (stored as matrices)
  43771. * @param uniform defines the webGL uniform location where to store the value
  43772. * @param matrices defines the array of float32 to store
  43773. */
  43774. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43775. /**
  43776. * Set the value of an uniform to a matrix (3x3)
  43777. * @param uniform defines the webGL uniform location where to store the value
  43778. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43779. */
  43780. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43781. /**
  43782. * Set the value of an uniform to a matrix (2x2)
  43783. * @param uniform defines the webGL uniform location where to store the value
  43784. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43785. */
  43786. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43787. /**
  43788. * Set the value of an uniform to a number (float)
  43789. * @param uniform defines the webGL uniform location where to store the value
  43790. * @param value defines the float number to store
  43791. */
  43792. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43793. /**
  43794. * Set the value of an uniform to a vec2
  43795. * @param uniform defines the webGL uniform location where to store the value
  43796. * @param x defines the 1st component of the value
  43797. * @param y defines the 2nd component of the value
  43798. */
  43799. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43800. /**
  43801. * Set the value of an uniform to a vec3
  43802. * @param uniform defines the webGL uniform location where to store the value
  43803. * @param x defines the 1st component of the value
  43804. * @param y defines the 2nd component of the value
  43805. * @param z defines the 3rd component of the value
  43806. */
  43807. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43808. /**
  43809. * Set the value of an uniform to a boolean
  43810. * @param uniform defines the webGL uniform location where to store the value
  43811. * @param bool defines the boolean to store
  43812. */
  43813. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43814. /**
  43815. * Set the value of an uniform to a vec4
  43816. * @param uniform defines the webGL uniform location where to store the value
  43817. * @param x defines the 1st component of the value
  43818. * @param y defines the 2nd component of the value
  43819. * @param z defines the 3rd component of the value
  43820. * @param w defines the 4th component of the value
  43821. */
  43822. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43823. /**
  43824. * Sets the current alpha mode
  43825. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43826. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43827. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43828. */
  43829. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43830. /**
  43831. * Bind webGl buffers directly to the webGL context
  43832. * @param vertexBuffers defines the vertex buffer to bind
  43833. * @param indexBuffer defines the index buffer to bind
  43834. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43835. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43836. * @param effect defines the effect associated with the vertex buffer
  43837. */
  43838. bindBuffers(vertexBuffers: {
  43839. [key: string]: VertexBuffer;
  43840. }, indexBuffer: DataBuffer, effect: Effect): void;
  43841. /**
  43842. * Force the entire cache to be cleared
  43843. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43844. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43845. */
  43846. wipeCaches(bruteForce?: boolean): void;
  43847. /**
  43848. * Send a draw order
  43849. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43850. * @param indexStart defines the starting index
  43851. * @param indexCount defines the number of index to draw
  43852. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43853. */
  43854. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43855. /**
  43856. * Draw a list of indexed primitives
  43857. * @param fillMode defines the primitive to use
  43858. * @param indexStart defines the starting index
  43859. * @param indexCount defines the number of index to draw
  43860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43861. */
  43862. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43863. /**
  43864. * Draw a list of unindexed primitives
  43865. * @param fillMode defines the primitive to use
  43866. * @param verticesStart defines the index of first vertex to draw
  43867. * @param verticesCount defines the count of vertices to draw
  43868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43869. */
  43870. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43871. /** @hidden */
  43872. _createTexture(): WebGLTexture;
  43873. /** @hidden */
  43874. _releaseTexture(texture: InternalTexture): void;
  43875. /**
  43876. * Usually called from Texture.ts.
  43877. * Passed information to create a WebGLTexture
  43878. * @param urlArg defines a value which contains one of the following:
  43879. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43880. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43881. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43882. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43883. * @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)
  43884. * @param scene needed for loading to the correct scene
  43885. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43886. * @param onLoad optional callback to be called upon successful completion
  43887. * @param onError optional callback to be called upon failure
  43888. * @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
  43889. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43890. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43891. * @param forcedExtension defines the extension to use to pick the right loader
  43892. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43893. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43894. */
  43895. 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;
  43896. /**
  43897. * Creates a new render target texture
  43898. * @param size defines the size of the texture
  43899. * @param options defines the options used to create the texture
  43900. * @returns a new render target texture stored in an InternalTexture
  43901. */
  43902. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43903. /**
  43904. * Update the sampling mode of a given texture
  43905. * @param samplingMode defines the required sampling mode
  43906. * @param texture defines the texture to update
  43907. */
  43908. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43909. /**
  43910. * Binds the frame buffer to the specified texture.
  43911. * @param texture The texture to render to or null for the default canvas
  43912. * @param faceIndex The face of the texture to render to in case of cube texture
  43913. * @param requiredWidth The width of the target to render to
  43914. * @param requiredHeight The height of the target to render to
  43915. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43916. * @param depthStencilTexture The depth stencil texture to use to render
  43917. * @param lodLevel defines le lod level to bind to the frame buffer
  43918. */
  43919. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43920. /**
  43921. * Unbind the current render target texture from the webGL context
  43922. * @param texture defines the render target texture to unbind
  43923. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43924. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43925. */
  43926. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43927. /**
  43928. * Creates a dynamic vertex buffer
  43929. * @param vertices the data for the dynamic vertex buffer
  43930. * @returns the new WebGL dynamic buffer
  43931. */
  43932. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43933. /**
  43934. * Update the content of a dynamic texture
  43935. * @param texture defines the texture to update
  43936. * @param canvas defines the canvas containing the source
  43937. * @param invertY defines if data must be stored with Y axis inverted
  43938. * @param premulAlpha defines if alpha is stored as premultiplied
  43939. * @param format defines the format of the data
  43940. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43941. */
  43942. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43943. /**
  43944. * Gets a boolean indicating if all created effects are ready
  43945. * @returns true if all effects are ready
  43946. */
  43947. areAllEffectsReady(): boolean;
  43948. /**
  43949. * @hidden
  43950. * Get the current error code of the webGL context
  43951. * @returns the error code
  43952. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43953. */
  43954. getError(): number;
  43955. /** @hidden */
  43956. _getUnpackAlignement(): number;
  43957. /** @hidden */
  43958. _unpackFlipY(value: boolean): void;
  43959. /**
  43960. * Update a dynamic index buffer
  43961. * @param indexBuffer defines the target index buffer
  43962. * @param indices defines the data to update
  43963. * @param offset defines the offset in the target index buffer where update should start
  43964. */
  43965. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43966. /**
  43967. * Updates a dynamic vertex buffer.
  43968. * @param vertexBuffer the vertex buffer to update
  43969. * @param vertices the data used to update the vertex buffer
  43970. * @param byteOffset the byte offset of the data (optional)
  43971. * @param byteLength the byte length of the data (optional)
  43972. */
  43973. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43974. /** @hidden */
  43975. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43976. /** @hidden */
  43977. _bindTexture(channel: number, texture: InternalTexture): void;
  43978. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43979. /**
  43980. * 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
  43981. */
  43982. releaseEffects(): void;
  43983. displayLoadingUI(): void;
  43984. hideLoadingUI(): void;
  43985. /** @hidden */
  43986. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43987. /** @hidden */
  43988. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43989. /** @hidden */
  43990. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43991. /** @hidden */
  43992. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43993. }
  43994. }
  43995. declare module BABYLON {
  43996. /** @hidden */
  43997. export class _OcclusionDataStorage {
  43998. /** @hidden */
  43999. occlusionInternalRetryCounter: number;
  44000. /** @hidden */
  44001. isOcclusionQueryInProgress: boolean;
  44002. /** @hidden */
  44003. isOccluded: boolean;
  44004. /** @hidden */
  44005. occlusionRetryCount: number;
  44006. /** @hidden */
  44007. occlusionType: number;
  44008. /** @hidden */
  44009. occlusionQueryAlgorithmType: number;
  44010. }
  44011. interface Engine {
  44012. /**
  44013. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44014. * @return the new query
  44015. */
  44016. createQuery(): WebGLQuery;
  44017. /**
  44018. * Delete and release a webGL query
  44019. * @param query defines the query to delete
  44020. * @return the current engine
  44021. */
  44022. deleteQuery(query: WebGLQuery): Engine;
  44023. /**
  44024. * Check if a given query has resolved and got its value
  44025. * @param query defines the query to check
  44026. * @returns true if the query got its value
  44027. */
  44028. isQueryResultAvailable(query: WebGLQuery): boolean;
  44029. /**
  44030. * Gets the value of a given query
  44031. * @param query defines the query to check
  44032. * @returns the value of the query
  44033. */
  44034. getQueryResult(query: WebGLQuery): number;
  44035. /**
  44036. * Initiates an occlusion query
  44037. * @param algorithmType defines the algorithm to use
  44038. * @param query defines the query to use
  44039. * @returns the current engine
  44040. * @see http://doc.babylonjs.com/features/occlusionquery
  44041. */
  44042. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44043. /**
  44044. * Ends an occlusion query
  44045. * @see http://doc.babylonjs.com/features/occlusionquery
  44046. * @param algorithmType defines the algorithm to use
  44047. * @returns the current engine
  44048. */
  44049. endOcclusionQuery(algorithmType: number): Engine;
  44050. /**
  44051. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44052. * Please note that only one query can be issued at a time
  44053. * @returns a time token used to track the time span
  44054. */
  44055. startTimeQuery(): Nullable<_TimeToken>;
  44056. /**
  44057. * Ends a time query
  44058. * @param token defines the token used to measure the time span
  44059. * @returns the time spent (in ns)
  44060. */
  44061. endTimeQuery(token: _TimeToken): int;
  44062. /** @hidden */
  44063. _currentNonTimestampToken: Nullable<_TimeToken>;
  44064. /** @hidden */
  44065. _createTimeQuery(): WebGLQuery;
  44066. /** @hidden */
  44067. _deleteTimeQuery(query: WebGLQuery): void;
  44068. /** @hidden */
  44069. _getGlAlgorithmType(algorithmType: number): number;
  44070. /** @hidden */
  44071. _getTimeQueryResult(query: WebGLQuery): any;
  44072. /** @hidden */
  44073. _getTimeQueryAvailability(query: WebGLQuery): any;
  44074. }
  44075. interface AbstractMesh {
  44076. /**
  44077. * Backing filed
  44078. * @hidden
  44079. */
  44080. __occlusionDataStorage: _OcclusionDataStorage;
  44081. /**
  44082. * Access property
  44083. * @hidden
  44084. */
  44085. _occlusionDataStorage: _OcclusionDataStorage;
  44086. /**
  44087. * 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.
  44088. * The default value is -1 which means don't break the query and wait till the result
  44089. * @see http://doc.babylonjs.com/features/occlusionquery
  44090. */
  44091. occlusionRetryCount: number;
  44092. /**
  44093. * 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:
  44094. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44095. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44096. * * 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.
  44097. * @see http://doc.babylonjs.com/features/occlusionquery
  44098. */
  44099. occlusionType: number;
  44100. /**
  44101. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44102. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44103. * * 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.
  44104. * @see http://doc.babylonjs.com/features/occlusionquery
  44105. */
  44106. occlusionQueryAlgorithmType: number;
  44107. /**
  44108. * 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
  44109. * @see http://doc.babylonjs.com/features/occlusionquery
  44110. */
  44111. isOccluded: boolean;
  44112. /**
  44113. * Flag to check the progress status of the query
  44114. * @see http://doc.babylonjs.com/features/occlusionquery
  44115. */
  44116. isOcclusionQueryInProgress: boolean;
  44117. }
  44118. }
  44119. declare module BABYLON {
  44120. /** @hidden */
  44121. export var _forceTransformFeedbackToBundle: boolean;
  44122. interface Engine {
  44123. /**
  44124. * Creates a webGL transform feedback object
  44125. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44126. * @returns the webGL transform feedback object
  44127. */
  44128. createTransformFeedback(): WebGLTransformFeedback;
  44129. /**
  44130. * Delete a webGL transform feedback object
  44131. * @param value defines the webGL transform feedback object to delete
  44132. */
  44133. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44134. /**
  44135. * Bind a webGL transform feedback object to the webgl context
  44136. * @param value defines the webGL transform feedback object to bind
  44137. */
  44138. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44139. /**
  44140. * Begins a transform feedback operation
  44141. * @param usePoints defines if points or triangles must be used
  44142. */
  44143. beginTransformFeedback(usePoints: boolean): void;
  44144. /**
  44145. * Ends a transform feedback operation
  44146. */
  44147. endTransformFeedback(): void;
  44148. /**
  44149. * Specify the varyings to use with transform feedback
  44150. * @param program defines the associated webGL program
  44151. * @param value defines the list of strings representing the varying names
  44152. */
  44153. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44154. /**
  44155. * Bind a webGL buffer for a transform feedback operation
  44156. * @param value defines the webGL buffer to bind
  44157. */
  44158. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44159. }
  44160. }
  44161. declare module BABYLON {
  44162. /**
  44163. * Creation options of the multi render target texture.
  44164. */
  44165. export interface IMultiRenderTargetOptions {
  44166. /**
  44167. * Define if the texture needs to create mip maps after render.
  44168. */
  44169. generateMipMaps?: boolean;
  44170. /**
  44171. * Define the types of all the draw buffers we want to create
  44172. */
  44173. types?: number[];
  44174. /**
  44175. * Define the sampling modes of all the draw buffers we want to create
  44176. */
  44177. samplingModes?: number[];
  44178. /**
  44179. * Define if a depth buffer is required
  44180. */
  44181. generateDepthBuffer?: boolean;
  44182. /**
  44183. * Define if a stencil buffer is required
  44184. */
  44185. generateStencilBuffer?: boolean;
  44186. /**
  44187. * Define if a depth texture is required instead of a depth buffer
  44188. */
  44189. generateDepthTexture?: boolean;
  44190. /**
  44191. * Define the number of desired draw buffers
  44192. */
  44193. textureCount?: number;
  44194. /**
  44195. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44196. */
  44197. doNotChangeAspectRatio?: boolean;
  44198. /**
  44199. * Define the default type of the buffers we are creating
  44200. */
  44201. defaultType?: number;
  44202. }
  44203. /**
  44204. * A multi render target, like a render target provides the ability to render to a texture.
  44205. * Unlike the render target, it can render to several draw buffers in one draw.
  44206. * This is specially interesting in deferred rendering or for any effects requiring more than
  44207. * just one color from a single pass.
  44208. */
  44209. export class MultiRenderTarget extends RenderTargetTexture {
  44210. private _internalTextures;
  44211. private _textures;
  44212. private _multiRenderTargetOptions;
  44213. /**
  44214. * Get if draw buffers are currently supported by the used hardware and browser.
  44215. */
  44216. readonly isSupported: boolean;
  44217. /**
  44218. * Get the list of textures generated by the multi render target.
  44219. */
  44220. readonly textures: Texture[];
  44221. /**
  44222. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  44223. */
  44224. readonly depthTexture: Texture;
  44225. /**
  44226. * Set the wrapping mode on U of all the textures we are rendering to.
  44227. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44228. */
  44229. wrapU: number;
  44230. /**
  44231. * Set the wrapping mode on V of all the textures we are rendering to.
  44232. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  44233. */
  44234. wrapV: number;
  44235. /**
  44236. * Instantiate a new multi render target texture.
  44237. * A multi render target, like a render target provides the ability to render to a texture.
  44238. * Unlike the render target, it can render to several draw buffers in one draw.
  44239. * This is specially interesting in deferred rendering or for any effects requiring more than
  44240. * just one color from a single pass.
  44241. * @param name Define the name of the texture
  44242. * @param size Define the size of the buffers to render to
  44243. * @param count Define the number of target we are rendering into
  44244. * @param scene Define the scene the texture belongs to
  44245. * @param options Define the options used to create the multi render target
  44246. */
  44247. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  44248. /** @hidden */
  44249. _rebuild(): void;
  44250. private _createInternalTextures;
  44251. private _createTextures;
  44252. /**
  44253. * Define the number of samples used if MSAA is enabled.
  44254. */
  44255. samples: number;
  44256. /**
  44257. * Resize all the textures in the multi render target.
  44258. * Be carrefull as it will recreate all the data in the new texture.
  44259. * @param size Define the new size
  44260. */
  44261. resize(size: any): void;
  44262. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  44263. /**
  44264. * Dispose the render targets and their associated resources
  44265. */
  44266. dispose(): void;
  44267. /**
  44268. * Release all the underlying texture used as draw buffers.
  44269. */
  44270. releaseInternalTextures(): void;
  44271. }
  44272. }
  44273. declare module BABYLON {
  44274. interface ThinEngine {
  44275. /**
  44276. * Unbind a list of render target textures from the webGL context
  44277. * This is used only when drawBuffer extension or webGL2 are active
  44278. * @param textures defines the render target textures to unbind
  44279. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  44280. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  44281. */
  44282. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  44283. /**
  44284. * Create a multi render target texture
  44285. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  44286. * @param size defines the size of the texture
  44287. * @param options defines the creation options
  44288. * @returns the cube texture as an InternalTexture
  44289. */
  44290. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  44291. /**
  44292. * Update the sample count for a given multiple render target texture
  44293. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  44294. * @param textures defines the textures to update
  44295. * @param samples defines the sample count to set
  44296. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  44297. */
  44298. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  44299. }
  44300. }
  44301. declare module BABYLON {
  44302. /** @hidden */
  44303. export var rgbdEncodePixelShader: {
  44304. name: string;
  44305. shader: string;
  44306. };
  44307. }
  44308. declare module BABYLON {
  44309. /** @hidden */
  44310. export var rgbdDecodePixelShader: {
  44311. name: string;
  44312. shader: string;
  44313. };
  44314. }
  44315. declare module BABYLON {
  44316. /**
  44317. * Raw texture data and descriptor sufficient for WebGL texture upload
  44318. */
  44319. export interface EnvironmentTextureInfo {
  44320. /**
  44321. * Version of the environment map
  44322. */
  44323. version: number;
  44324. /**
  44325. * Width of image
  44326. */
  44327. width: number;
  44328. /**
  44329. * Irradiance information stored in the file.
  44330. */
  44331. irradiance: any;
  44332. /**
  44333. * Specular information stored in the file.
  44334. */
  44335. specular: any;
  44336. }
  44337. /**
  44338. * Defines One Image in the file. It requires only the position in the file
  44339. * as well as the length.
  44340. */
  44341. interface BufferImageData {
  44342. /**
  44343. * Length of the image data.
  44344. */
  44345. length: number;
  44346. /**
  44347. * Position of the data from the null terminator delimiting the end of the JSON.
  44348. */
  44349. position: number;
  44350. }
  44351. /**
  44352. * Defines the specular data enclosed in the file.
  44353. * This corresponds to the version 1 of the data.
  44354. */
  44355. export interface EnvironmentTextureSpecularInfoV1 {
  44356. /**
  44357. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  44358. */
  44359. specularDataPosition?: number;
  44360. /**
  44361. * This contains all the images data needed to reconstruct the cubemap.
  44362. */
  44363. mipmaps: Array<BufferImageData>;
  44364. /**
  44365. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  44366. */
  44367. lodGenerationScale: number;
  44368. }
  44369. /**
  44370. * Sets of helpers addressing the serialization and deserialization of environment texture
  44371. * stored in a BabylonJS env file.
  44372. * Those files are usually stored as .env files.
  44373. */
  44374. export class EnvironmentTextureTools {
  44375. /**
  44376. * Magic number identifying the env file.
  44377. */
  44378. private static _MagicBytes;
  44379. /**
  44380. * Gets the environment info from an env file.
  44381. * @param data The array buffer containing the .env bytes.
  44382. * @returns the environment file info (the json header) if successfully parsed.
  44383. */
  44384. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44385. /**
  44386. * Creates an environment texture from a loaded cube texture.
  44387. * @param texture defines the cube texture to convert in env file
  44388. * @return a promise containing the environment data if succesfull.
  44389. */
  44390. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44391. /**
  44392. * Creates a JSON representation of the spherical data.
  44393. * @param texture defines the texture containing the polynomials
  44394. * @return the JSON representation of the spherical info
  44395. */
  44396. private static _CreateEnvTextureIrradiance;
  44397. /**
  44398. * Creates the ArrayBufferViews used for initializing environment texture image data.
  44399. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  44400. * @param info parameters that determine what views will be created for accessing the underlying buffer
  44401. * @return the views described by info providing access to the underlying buffer
  44402. */
  44403. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  44404. /**
  44405. * Uploads the texture info contained in the env file to the GPU.
  44406. * @param texture defines the internal texture to upload to
  44407. * @param arrayBuffer defines the buffer cotaining the data to load
  44408. * @param info defines the texture info retrieved through the GetEnvInfo method
  44409. * @returns a promise
  44410. */
  44411. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44412. /**
  44413. * Uploads the levels of image data to the GPU.
  44414. * @param texture defines the internal texture to upload to
  44415. * @param imageData defines the array buffer views of image data [mipmap][face]
  44416. * @returns a promise
  44417. */
  44418. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44419. /**
  44420. * Uploads spherical polynomials information to the texture.
  44421. * @param texture defines the texture we are trying to upload the information to
  44422. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44423. */
  44424. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44425. /** @hidden */
  44426. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44427. }
  44428. }
  44429. declare module BABYLON {
  44430. /**
  44431. * Contains position and normal vectors for a vertex
  44432. */
  44433. export class PositionNormalVertex {
  44434. /** the position of the vertex (defaut: 0,0,0) */
  44435. position: Vector3;
  44436. /** the normal of the vertex (defaut: 0,1,0) */
  44437. normal: Vector3;
  44438. /**
  44439. * Creates a PositionNormalVertex
  44440. * @param position the position of the vertex (defaut: 0,0,0)
  44441. * @param normal the normal of the vertex (defaut: 0,1,0)
  44442. */
  44443. constructor(
  44444. /** the position of the vertex (defaut: 0,0,0) */
  44445. position?: Vector3,
  44446. /** the normal of the vertex (defaut: 0,1,0) */
  44447. normal?: Vector3);
  44448. /**
  44449. * Clones the PositionNormalVertex
  44450. * @returns the cloned PositionNormalVertex
  44451. */
  44452. clone(): PositionNormalVertex;
  44453. }
  44454. /**
  44455. * Contains position, normal and uv vectors for a vertex
  44456. */
  44457. export class PositionNormalTextureVertex {
  44458. /** the position of the vertex (defaut: 0,0,0) */
  44459. position: Vector3;
  44460. /** the normal of the vertex (defaut: 0,1,0) */
  44461. normal: Vector3;
  44462. /** the uv of the vertex (default: 0,0) */
  44463. uv: Vector2;
  44464. /**
  44465. * Creates a PositionNormalTextureVertex
  44466. * @param position the position of the vertex (defaut: 0,0,0)
  44467. * @param normal the normal of the vertex (defaut: 0,1,0)
  44468. * @param uv the uv of the vertex (default: 0,0)
  44469. */
  44470. constructor(
  44471. /** the position of the vertex (defaut: 0,0,0) */
  44472. position?: Vector3,
  44473. /** the normal of the vertex (defaut: 0,1,0) */
  44474. normal?: Vector3,
  44475. /** the uv of the vertex (default: 0,0) */
  44476. uv?: Vector2);
  44477. /**
  44478. * Clones the PositionNormalTextureVertex
  44479. * @returns the cloned PositionNormalTextureVertex
  44480. */
  44481. clone(): PositionNormalTextureVertex;
  44482. }
  44483. }
  44484. declare module BABYLON {
  44485. /** @hidden */
  44486. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  44487. private _genericAttributeLocation;
  44488. private _varyingLocationCount;
  44489. private _varyingLocationMap;
  44490. private _replacements;
  44491. private _textureCount;
  44492. private _uniforms;
  44493. lineProcessor(line: string): string;
  44494. attributeProcessor(attribute: string): string;
  44495. varyingProcessor(varying: string, isFragment: boolean): string;
  44496. uniformProcessor(uniform: string): string;
  44497. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  44498. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  44499. }
  44500. }
  44501. declare module BABYLON {
  44502. /**
  44503. * Container for accessors for natively-stored mesh data buffers.
  44504. */
  44505. class NativeDataBuffer extends DataBuffer {
  44506. /**
  44507. * Accessor value used to identify/retrieve a natively-stored index buffer.
  44508. */
  44509. nativeIndexBuffer?: any;
  44510. /**
  44511. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  44512. */
  44513. nativeVertexBuffer?: any;
  44514. }
  44515. /** @hidden */
  44516. export class NativeEngine extends Engine {
  44517. private readonly _native;
  44518. getHardwareScalingLevel(): number;
  44519. constructor();
  44520. /**
  44521. * Can be used to override the current requestAnimationFrame requester.
  44522. * @hidden
  44523. */
  44524. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  44525. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44526. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  44527. createVertexBuffer(data: DataArray): NativeDataBuffer;
  44528. recordVertexArrayObject(vertexBuffers: {
  44529. [key: string]: VertexBuffer;
  44530. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  44531. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44532. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  44533. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44534. /**
  44535. * Draw a list of indexed primitives
  44536. * @param fillMode defines the primitive to use
  44537. * @param indexStart defines the starting index
  44538. * @param indexCount defines the number of index to draw
  44539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44540. */
  44541. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44542. /**
  44543. * Draw a list of unindexed primitives
  44544. * @param fillMode defines the primitive to use
  44545. * @param verticesStart defines the index of first vertex to draw
  44546. * @param verticesCount defines the count of vertices to draw
  44547. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  44548. */
  44549. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44550. createPipelineContext(): IPipelineContext;
  44551. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  44552. /** @hidden */
  44553. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  44554. /** @hidden */
  44555. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  44556. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44557. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  44558. protected _setProgram(program: WebGLProgram): void;
  44559. _releaseEffect(effect: Effect): void;
  44560. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  44561. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  44562. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  44563. bindSamplers(effect: Effect): void;
  44564. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  44565. getRenderWidth(useScreen?: boolean): number;
  44566. getRenderHeight(useScreen?: boolean): number;
  44567. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  44568. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44569. /**
  44570. * Set the z offset to apply to current rendering
  44571. * @param value defines the offset to apply
  44572. */
  44573. setZOffset(value: number): void;
  44574. /**
  44575. * Gets the current value of the zOffset
  44576. * @returns the current zOffset state
  44577. */
  44578. getZOffset(): number;
  44579. /**
  44580. * Enable or disable depth buffering
  44581. * @param enable defines the state to set
  44582. */
  44583. setDepthBuffer(enable: boolean): void;
  44584. /**
  44585. * Gets a boolean indicating if depth writing is enabled
  44586. * @returns the current depth writing state
  44587. */
  44588. getDepthWrite(): boolean;
  44589. /**
  44590. * Enable or disable depth writing
  44591. * @param enable defines the state to set
  44592. */
  44593. setDepthWrite(enable: boolean): void;
  44594. /**
  44595. * Enable or disable color writing
  44596. * @param enable defines the state to set
  44597. */
  44598. setColorWrite(enable: boolean): void;
  44599. /**
  44600. * Gets a boolean indicating if color writing is enabled
  44601. * @returns the current color writing state
  44602. */
  44603. getColorWrite(): boolean;
  44604. /**
  44605. * Sets alpha constants used by some alpha blending modes
  44606. * @param r defines the red component
  44607. * @param g defines the green component
  44608. * @param b defines the blue component
  44609. * @param a defines the alpha component
  44610. */
  44611. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  44612. /**
  44613. * Sets the current alpha mode
  44614. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  44615. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  44616. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44617. */
  44618. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44619. /**
  44620. * Gets the current alpha mode
  44621. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  44622. * @returns the current alpha mode
  44623. */
  44624. getAlphaMode(): number;
  44625. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44626. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44627. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44628. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44629. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44630. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44631. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44632. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44633. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44634. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44635. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44636. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44637. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44638. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44639. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44640. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44641. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44642. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44643. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44644. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44645. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  44646. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  44647. wipeCaches(bruteForce?: boolean): void;
  44648. _createTexture(): WebGLTexture;
  44649. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  44650. /**
  44651. * Usually called from BABYLON.Texture.ts.
  44652. * Passed information to create a WebGLTexture
  44653. * @param urlArg defines a value which contains one of the following:
  44654. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  44655. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  44656. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  44657. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  44658. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  44659. * @param scene needed for loading to the correct scene
  44660. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  44661. * @param onLoad optional callback to be called upon successful completion
  44662. * @param onError optional callback to be called upon failure
  44663. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  44664. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  44665. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  44666. * @param forcedExtension defines the extension to use to pick the right loader
  44667. * @returns a InternalTexture for assignment back into BABYLON.Texture
  44668. */
  44669. 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;
  44670. /**
  44671. * Creates a cube texture
  44672. * @param rootUrl defines the url where the files to load is located
  44673. * @param scene defines the current scene
  44674. * @param files defines the list of files to load (1 per face)
  44675. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  44676. * @param onLoad defines an optional callback raised when the texture is loaded
  44677. * @param onError defines an optional callback raised if there is an issue to load the texture
  44678. * @param format defines the format of the data
  44679. * @param forcedExtension defines the extension to use to pick the right loader
  44680. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44681. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44682. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44683. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44684. * @returns the cube texture as an InternalTexture
  44685. */
  44686. 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;
  44687. private _getSamplingFilter;
  44688. private static _GetNativeTextureFormat;
  44689. createRenderTargetTexture(size: number | {
  44690. width: number;
  44691. height: number;
  44692. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44693. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44694. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44695. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44696. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44697. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44698. /**
  44699. * Updates a dynamic vertex buffer.
  44700. * @param vertexBuffer the vertex buffer to update
  44701. * @param data the data used to update the vertex buffer
  44702. * @param byteOffset the byte offset of the data (optional)
  44703. * @param byteLength the byte length of the data (optional)
  44704. */
  44705. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44706. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44707. private _updateAnisotropicLevel;
  44708. private _getAddressMode;
  44709. /** @hidden */
  44710. _bindTexture(channel: number, texture: InternalTexture): void;
  44711. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44712. releaseEffects(): void;
  44713. /** @hidden */
  44714. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44715. /** @hidden */
  44716. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44717. /** @hidden */
  44718. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44719. /** @hidden */
  44720. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44721. }
  44722. }
  44723. declare module BABYLON {
  44724. /**
  44725. * Gather the list of clipboard event types as constants.
  44726. */
  44727. export class ClipboardEventTypes {
  44728. /**
  44729. * The clipboard event is fired when a copy command is active (pressed).
  44730. */
  44731. static readonly COPY: number;
  44732. /**
  44733. * The clipboard event is fired when a cut command is active (pressed).
  44734. */
  44735. static readonly CUT: number;
  44736. /**
  44737. * The clipboard event is fired when a paste command is active (pressed).
  44738. */
  44739. static readonly PASTE: number;
  44740. }
  44741. /**
  44742. * This class is used to store clipboard related info for the onClipboardObservable event.
  44743. */
  44744. export class ClipboardInfo {
  44745. /**
  44746. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44747. */
  44748. type: number;
  44749. /**
  44750. * Defines the related dom event
  44751. */
  44752. event: ClipboardEvent;
  44753. /**
  44754. *Creates an instance of ClipboardInfo.
  44755. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44756. * @param event Defines the related dom event
  44757. */
  44758. constructor(
  44759. /**
  44760. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44761. */
  44762. type: number,
  44763. /**
  44764. * Defines the related dom event
  44765. */
  44766. event: ClipboardEvent);
  44767. /**
  44768. * Get the clipboard event's type from the keycode.
  44769. * @param keyCode Defines the keyCode for the current keyboard event.
  44770. * @return {number}
  44771. */
  44772. static GetTypeFromCharacter(keyCode: number): number;
  44773. }
  44774. }
  44775. declare module BABYLON {
  44776. /**
  44777. * Google Daydream controller
  44778. */
  44779. export class DaydreamController extends WebVRController {
  44780. /**
  44781. * Base Url for the controller model.
  44782. */
  44783. static MODEL_BASE_URL: string;
  44784. /**
  44785. * File name for the controller model.
  44786. */
  44787. static MODEL_FILENAME: string;
  44788. /**
  44789. * Gamepad Id prefix used to identify Daydream Controller.
  44790. */
  44791. static readonly GAMEPAD_ID_PREFIX: string;
  44792. /**
  44793. * Creates a new DaydreamController from a gamepad
  44794. * @param vrGamepad the gamepad that the controller should be created from
  44795. */
  44796. constructor(vrGamepad: any);
  44797. /**
  44798. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44799. * @param scene scene in which to add meshes
  44800. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44801. */
  44802. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44803. /**
  44804. * Called once for each button that changed state since the last frame
  44805. * @param buttonIdx Which button index changed
  44806. * @param state New state of the button
  44807. * @param changes Which properties on the state changed since last frame
  44808. */
  44809. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44810. }
  44811. }
  44812. declare module BABYLON {
  44813. /**
  44814. * Gear VR Controller
  44815. */
  44816. export class GearVRController extends WebVRController {
  44817. /**
  44818. * Base Url for the controller model.
  44819. */
  44820. static MODEL_BASE_URL: string;
  44821. /**
  44822. * File name for the controller model.
  44823. */
  44824. static MODEL_FILENAME: string;
  44825. /**
  44826. * Gamepad Id prefix used to identify this controller.
  44827. */
  44828. static readonly GAMEPAD_ID_PREFIX: string;
  44829. private readonly _buttonIndexToObservableNameMap;
  44830. /**
  44831. * Creates a new GearVRController from a gamepad
  44832. * @param vrGamepad the gamepad that the controller should be created from
  44833. */
  44834. constructor(vrGamepad: any);
  44835. /**
  44836. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44837. * @param scene scene in which to add meshes
  44838. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44839. */
  44840. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44841. /**
  44842. * Called once for each button that changed state since the last frame
  44843. * @param buttonIdx Which button index changed
  44844. * @param state New state of the button
  44845. * @param changes Which properties on the state changed since last frame
  44846. */
  44847. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44848. }
  44849. }
  44850. declare module BABYLON {
  44851. /**
  44852. * Class containing static functions to help procedurally build meshes
  44853. */
  44854. export class PolyhedronBuilder {
  44855. /**
  44856. * Creates a polyhedron mesh
  44857. * * 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
  44858. * * The parameter `size` (positive float, default 1) sets the polygon size
  44859. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44860. * * 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`
  44861. * * 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
  44862. * * 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)`)
  44863. * * 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
  44864. * * 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
  44865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44866. * * 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
  44867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44868. * @param name defines the name of the mesh
  44869. * @param options defines the options used to create the mesh
  44870. * @param scene defines the hosting scene
  44871. * @returns the polyhedron mesh
  44872. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44873. */
  44874. static CreatePolyhedron(name: string, options: {
  44875. type?: number;
  44876. size?: number;
  44877. sizeX?: number;
  44878. sizeY?: number;
  44879. sizeZ?: number;
  44880. custom?: any;
  44881. faceUV?: Vector4[];
  44882. faceColors?: Color4[];
  44883. flat?: boolean;
  44884. updatable?: boolean;
  44885. sideOrientation?: number;
  44886. frontUVs?: Vector4;
  44887. backUVs?: Vector4;
  44888. }, scene?: Nullable<Scene>): Mesh;
  44889. }
  44890. }
  44891. declare module BABYLON {
  44892. /**
  44893. * Gizmo that enables scaling a mesh along 3 axis
  44894. */
  44895. export class ScaleGizmo extends Gizmo {
  44896. /**
  44897. * Internal gizmo used for interactions on the x axis
  44898. */
  44899. xGizmo: AxisScaleGizmo;
  44900. /**
  44901. * Internal gizmo used for interactions on the y axis
  44902. */
  44903. yGizmo: AxisScaleGizmo;
  44904. /**
  44905. * Internal gizmo used for interactions on the z axis
  44906. */
  44907. zGizmo: AxisScaleGizmo;
  44908. /**
  44909. * Internal gizmo used to scale all axis equally
  44910. */
  44911. uniformScaleGizmo: AxisScaleGizmo;
  44912. private _meshAttached;
  44913. private _updateGizmoRotationToMatchAttachedMesh;
  44914. private _snapDistance;
  44915. private _scaleRatio;
  44916. private _uniformScalingMesh;
  44917. private _octahedron;
  44918. /** Fires an event when any of it's sub gizmos are dragged */
  44919. onDragStartObservable: Observable<unknown>;
  44920. /** Fires an event when any of it's sub gizmos are released from dragging */
  44921. onDragEndObservable: Observable<unknown>;
  44922. attachedMesh: Nullable<AbstractMesh>;
  44923. /**
  44924. * Creates a ScaleGizmo
  44925. * @param gizmoLayer The utility layer the gizmo will be added to
  44926. */
  44927. constructor(gizmoLayer?: UtilityLayerRenderer);
  44928. updateGizmoRotationToMatchAttachedMesh: boolean;
  44929. /**
  44930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44931. */
  44932. snapDistance: number;
  44933. /**
  44934. * Ratio for the scale of the gizmo (Default: 1)
  44935. */
  44936. scaleRatio: number;
  44937. /**
  44938. * Disposes of the gizmo
  44939. */
  44940. dispose(): void;
  44941. }
  44942. }
  44943. declare module BABYLON {
  44944. /**
  44945. * Single axis scale gizmo
  44946. */
  44947. export class AxisScaleGizmo extends Gizmo {
  44948. /**
  44949. * Drag behavior responsible for the gizmos dragging interactions
  44950. */
  44951. dragBehavior: PointerDragBehavior;
  44952. private _pointerObserver;
  44953. /**
  44954. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44955. */
  44956. snapDistance: number;
  44957. /**
  44958. * Event that fires each time the gizmo snaps to a new location.
  44959. * * snapDistance is the the change in distance
  44960. */
  44961. onSnapObservable: Observable<{
  44962. snapDistance: number;
  44963. }>;
  44964. /**
  44965. * If the scaling operation should be done on all axis (default: false)
  44966. */
  44967. uniformScaling: boolean;
  44968. private _isEnabled;
  44969. private _parent;
  44970. private _arrow;
  44971. private _coloredMaterial;
  44972. private _hoverMaterial;
  44973. /**
  44974. * Creates an AxisScaleGizmo
  44975. * @param gizmoLayer The utility layer the gizmo will be added to
  44976. * @param dragAxis The axis which the gizmo will be able to scale on
  44977. * @param color The color of the gizmo
  44978. */
  44979. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44980. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44981. /**
  44982. * If the gizmo is enabled
  44983. */
  44984. isEnabled: boolean;
  44985. /**
  44986. * Disposes of the gizmo
  44987. */
  44988. dispose(): void;
  44989. /**
  44990. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44991. * @param mesh The mesh to replace the default mesh of the gizmo
  44992. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44993. */
  44994. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44995. }
  44996. }
  44997. declare module BABYLON {
  44998. /**
  44999. * Bounding box gizmo
  45000. */
  45001. export class BoundingBoxGizmo extends Gizmo {
  45002. private _lineBoundingBox;
  45003. private _rotateSpheresParent;
  45004. private _scaleBoxesParent;
  45005. private _boundingDimensions;
  45006. private _renderObserver;
  45007. private _pointerObserver;
  45008. private _scaleDragSpeed;
  45009. private _tmpQuaternion;
  45010. private _tmpVector;
  45011. private _tmpRotationMatrix;
  45012. /**
  45013. * 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)
  45014. */
  45015. ignoreChildren: boolean;
  45016. /**
  45017. * 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)
  45018. */
  45019. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45020. /**
  45021. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45022. */
  45023. rotationSphereSize: number;
  45024. /**
  45025. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45026. */
  45027. scaleBoxSize: number;
  45028. /**
  45029. * 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)
  45030. */
  45031. fixedDragMeshScreenSize: boolean;
  45032. /**
  45033. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45034. */
  45035. fixedDragMeshScreenSizeDistanceFactor: number;
  45036. /**
  45037. * Fired when a rotation sphere or scale box is dragged
  45038. */
  45039. onDragStartObservable: Observable<{}>;
  45040. /**
  45041. * Fired when a scale box is dragged
  45042. */
  45043. onScaleBoxDragObservable: Observable<{}>;
  45044. /**
  45045. * Fired when a scale box drag is ended
  45046. */
  45047. onScaleBoxDragEndObservable: Observable<{}>;
  45048. /**
  45049. * Fired when a rotation sphere is dragged
  45050. */
  45051. onRotationSphereDragObservable: Observable<{}>;
  45052. /**
  45053. * Fired when a rotation sphere drag is ended
  45054. */
  45055. onRotationSphereDragEndObservable: Observable<{}>;
  45056. /**
  45057. * 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)
  45058. */
  45059. scalePivot: Nullable<Vector3>;
  45060. /**
  45061. * Mesh used as a pivot to rotate the attached mesh
  45062. */
  45063. private _anchorMesh;
  45064. private _existingMeshScale;
  45065. private _dragMesh;
  45066. private pointerDragBehavior;
  45067. private coloredMaterial;
  45068. private hoverColoredMaterial;
  45069. /**
  45070. * Sets the color of the bounding box gizmo
  45071. * @param color the color to set
  45072. */
  45073. setColor(color: Color3): void;
  45074. /**
  45075. * Creates an BoundingBoxGizmo
  45076. * @param gizmoLayer The utility layer the gizmo will be added to
  45077. * @param color The color of the gizmo
  45078. */
  45079. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45080. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45081. private _selectNode;
  45082. /**
  45083. * Updates the bounding box information for the Gizmo
  45084. */
  45085. updateBoundingBox(): void;
  45086. private _updateRotationSpheres;
  45087. private _updateScaleBoxes;
  45088. /**
  45089. * Enables rotation on the specified axis and disables rotation on the others
  45090. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45091. */
  45092. setEnabledRotationAxis(axis: string): void;
  45093. /**
  45094. * Enables/disables scaling
  45095. * @param enable if scaling should be enabled
  45096. */
  45097. setEnabledScaling(enable: boolean): void;
  45098. private _updateDummy;
  45099. /**
  45100. * Enables a pointer drag behavior on the bounding box of the gizmo
  45101. */
  45102. enableDragBehavior(): void;
  45103. /**
  45104. * Disposes of the gizmo
  45105. */
  45106. dispose(): void;
  45107. /**
  45108. * 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)
  45109. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45110. * @returns the bounding box mesh with the passed in mesh as a child
  45111. */
  45112. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45113. /**
  45114. * CustomMeshes are not supported by this gizmo
  45115. * @param mesh The mesh to replace the default mesh of the gizmo
  45116. */
  45117. setCustomMesh(mesh: Mesh): void;
  45118. }
  45119. }
  45120. declare module BABYLON {
  45121. /**
  45122. * Single plane rotation gizmo
  45123. */
  45124. export class PlaneRotationGizmo extends Gizmo {
  45125. /**
  45126. * Drag behavior responsible for the gizmos dragging interactions
  45127. */
  45128. dragBehavior: PointerDragBehavior;
  45129. private _pointerObserver;
  45130. /**
  45131. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45132. */
  45133. snapDistance: number;
  45134. /**
  45135. * Event that fires each time the gizmo snaps to a new location.
  45136. * * snapDistance is the the change in distance
  45137. */
  45138. onSnapObservable: Observable<{
  45139. snapDistance: number;
  45140. }>;
  45141. private _isEnabled;
  45142. private _parent;
  45143. /**
  45144. * Creates a PlaneRotationGizmo
  45145. * @param gizmoLayer The utility layer the gizmo will be added to
  45146. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45147. * @param color The color of the gizmo
  45148. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45149. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45150. */
  45151. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  45152. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45153. /**
  45154. * If the gizmo is enabled
  45155. */
  45156. isEnabled: boolean;
  45157. /**
  45158. * Disposes of the gizmo
  45159. */
  45160. dispose(): void;
  45161. }
  45162. }
  45163. declare module BABYLON {
  45164. /**
  45165. * Gizmo that enables rotating a mesh along 3 axis
  45166. */
  45167. export class RotationGizmo extends Gizmo {
  45168. /**
  45169. * Internal gizmo used for interactions on the x axis
  45170. */
  45171. xGizmo: PlaneRotationGizmo;
  45172. /**
  45173. * Internal gizmo used for interactions on the y axis
  45174. */
  45175. yGizmo: PlaneRotationGizmo;
  45176. /**
  45177. * Internal gizmo used for interactions on the z axis
  45178. */
  45179. zGizmo: PlaneRotationGizmo;
  45180. /** Fires an event when any of it's sub gizmos are dragged */
  45181. onDragStartObservable: Observable<unknown>;
  45182. /** Fires an event when any of it's sub gizmos are released from dragging */
  45183. onDragEndObservable: Observable<unknown>;
  45184. private _meshAttached;
  45185. attachedMesh: Nullable<AbstractMesh>;
  45186. /**
  45187. * Creates a RotationGizmo
  45188. * @param gizmoLayer The utility layer the gizmo will be added to
  45189. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45190. * @param useEulerRotation Use and update Euler angle instead of quaternion
  45191. */
  45192. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  45193. updateGizmoRotationToMatchAttachedMesh: boolean;
  45194. /**
  45195. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45196. */
  45197. snapDistance: number;
  45198. /**
  45199. * Ratio for the scale of the gizmo (Default: 1)
  45200. */
  45201. scaleRatio: number;
  45202. /**
  45203. * Disposes of the gizmo
  45204. */
  45205. dispose(): void;
  45206. /**
  45207. * CustomMeshes are not supported by this gizmo
  45208. * @param mesh The mesh to replace the default mesh of the gizmo
  45209. */
  45210. setCustomMesh(mesh: Mesh): void;
  45211. }
  45212. }
  45213. declare module BABYLON {
  45214. /**
  45215. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45216. */
  45217. export class GizmoManager implements IDisposable {
  45218. private scene;
  45219. /**
  45220. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45221. */
  45222. gizmos: {
  45223. positionGizmo: Nullable<PositionGizmo>;
  45224. rotationGizmo: Nullable<RotationGizmo>;
  45225. scaleGizmo: Nullable<ScaleGizmo>;
  45226. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45227. };
  45228. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45229. clearGizmoOnEmptyPointerEvent: boolean;
  45230. /** Fires an event when the manager is attached to a mesh */
  45231. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45232. private _gizmosEnabled;
  45233. private _pointerObserver;
  45234. private _attachedMesh;
  45235. private _boundingBoxColor;
  45236. private _defaultUtilityLayer;
  45237. private _defaultKeepDepthUtilityLayer;
  45238. /**
  45239. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45240. */
  45241. boundingBoxDragBehavior: SixDofDragBehavior;
  45242. /**
  45243. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45244. */
  45245. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45246. /**
  45247. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45248. */
  45249. usePointerToAttachGizmos: boolean;
  45250. /**
  45251. * Utility layer that the bounding box gizmo belongs to
  45252. */
  45253. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45254. /**
  45255. * Utility layer that all gizmos besides bounding box belong to
  45256. */
  45257. readonly utilityLayer: UtilityLayerRenderer;
  45258. /**
  45259. * Instatiates a gizmo manager
  45260. * @param scene the scene to overlay the gizmos on top of
  45261. */
  45262. constructor(scene: Scene);
  45263. /**
  45264. * Attaches a set of gizmos to the specified mesh
  45265. * @param mesh The mesh the gizmo's should be attached to
  45266. */
  45267. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45268. /**
  45269. * If the position gizmo is enabled
  45270. */
  45271. positionGizmoEnabled: boolean;
  45272. /**
  45273. * If the rotation gizmo is enabled
  45274. */
  45275. rotationGizmoEnabled: boolean;
  45276. /**
  45277. * If the scale gizmo is enabled
  45278. */
  45279. scaleGizmoEnabled: boolean;
  45280. /**
  45281. * If the boundingBox gizmo is enabled
  45282. */
  45283. boundingBoxGizmoEnabled: boolean;
  45284. /**
  45285. * Disposes of the gizmo manager
  45286. */
  45287. dispose(): void;
  45288. }
  45289. }
  45290. declare module BABYLON {
  45291. /**
  45292. * A directional light is defined by a direction (what a surprise!).
  45293. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45294. * 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.
  45295. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45296. */
  45297. export class DirectionalLight extends ShadowLight {
  45298. private _shadowFrustumSize;
  45299. /**
  45300. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45301. */
  45302. /**
  45303. * Specifies a fix frustum size for the shadow generation.
  45304. */
  45305. shadowFrustumSize: number;
  45306. private _shadowOrthoScale;
  45307. /**
  45308. * Gets the shadow projection scale against the optimal computed one.
  45309. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45310. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45311. */
  45312. /**
  45313. * Sets the shadow projection scale against the optimal computed one.
  45314. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45315. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45316. */
  45317. shadowOrthoScale: number;
  45318. /**
  45319. * Automatically compute the projection matrix to best fit (including all the casters)
  45320. * on each frame.
  45321. */
  45322. autoUpdateExtends: boolean;
  45323. private _orthoLeft;
  45324. private _orthoRight;
  45325. private _orthoTop;
  45326. private _orthoBottom;
  45327. /**
  45328. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45329. * The directional light is emitted from everywhere in the given direction.
  45330. * It can cast shadows.
  45331. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45332. * @param name The friendly name of the light
  45333. * @param direction The direction of the light
  45334. * @param scene The scene the light belongs to
  45335. */
  45336. constructor(name: string, direction: Vector3, scene: Scene);
  45337. /**
  45338. * Returns the string "DirectionalLight".
  45339. * @return The class name
  45340. */
  45341. getClassName(): string;
  45342. /**
  45343. * Returns the integer 1.
  45344. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45345. */
  45346. getTypeID(): number;
  45347. /**
  45348. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45349. * Returns the DirectionalLight Shadow projection matrix.
  45350. */
  45351. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45352. /**
  45353. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45354. * Returns the DirectionalLight Shadow projection matrix.
  45355. */
  45356. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45357. /**
  45358. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45359. * Returns the DirectionalLight Shadow projection matrix.
  45360. */
  45361. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45362. protected _buildUniformLayout(): void;
  45363. /**
  45364. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45365. * @param effect The effect to update
  45366. * @param lightIndex The index of the light in the effect to update
  45367. * @returns The directional light
  45368. */
  45369. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45370. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  45371. /**
  45372. * Gets the minZ used for shadow according to both the scene and the light.
  45373. *
  45374. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45375. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45376. * @param activeCamera The camera we are returning the min for
  45377. * @returns the depth min z
  45378. */
  45379. getDepthMinZ(activeCamera: Camera): number;
  45380. /**
  45381. * Gets the maxZ used for shadow according to both the scene and the light.
  45382. *
  45383. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45384. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45385. * @param activeCamera The camera we are returning the max for
  45386. * @returns the depth max z
  45387. */
  45388. getDepthMaxZ(activeCamera: Camera): number;
  45389. /**
  45390. * Prepares the list of defines specific to the light type.
  45391. * @param defines the list of defines
  45392. * @param lightIndex defines the index of the light for the effect
  45393. */
  45394. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45395. }
  45396. }
  45397. declare module BABYLON {
  45398. /**
  45399. * Class containing static functions to help procedurally build meshes
  45400. */
  45401. export class HemisphereBuilder {
  45402. /**
  45403. * Creates a hemisphere mesh
  45404. * @param name defines the name of the mesh
  45405. * @param options defines the options used to create the mesh
  45406. * @param scene defines the hosting scene
  45407. * @returns the hemisphere mesh
  45408. */
  45409. static CreateHemisphere(name: string, options: {
  45410. segments?: number;
  45411. diameter?: number;
  45412. sideOrientation?: number;
  45413. }, scene: any): Mesh;
  45414. }
  45415. }
  45416. declare module BABYLON {
  45417. /**
  45418. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45419. * These values define a cone of light starting from the position, emitting toward the direction.
  45420. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45421. * and the exponent defines the speed of the decay of the light with distance (reach).
  45422. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45423. */
  45424. export class SpotLight extends ShadowLight {
  45425. private _angle;
  45426. private _innerAngle;
  45427. private _cosHalfAngle;
  45428. private _lightAngleScale;
  45429. private _lightAngleOffset;
  45430. /**
  45431. * Gets the cone angle of the spot light in Radians.
  45432. */
  45433. /**
  45434. * Sets the cone angle of the spot light in Radians.
  45435. */
  45436. angle: number;
  45437. /**
  45438. * Only used in gltf falloff mode, this defines the angle where
  45439. * the directional falloff will start before cutting at angle which could be seen
  45440. * as outer angle.
  45441. */
  45442. /**
  45443. * Only used in gltf falloff mode, this defines the angle where
  45444. * the directional falloff will start before cutting at angle which could be seen
  45445. * as outer angle.
  45446. */
  45447. innerAngle: number;
  45448. private _shadowAngleScale;
  45449. /**
  45450. * Allows scaling the angle of the light for shadow generation only.
  45451. */
  45452. /**
  45453. * Allows scaling the angle of the light for shadow generation only.
  45454. */
  45455. shadowAngleScale: number;
  45456. /**
  45457. * The light decay speed with the distance from the emission spot.
  45458. */
  45459. exponent: number;
  45460. private _projectionTextureMatrix;
  45461. /**
  45462. * Allows reading the projecton texture
  45463. */
  45464. readonly projectionTextureMatrix: Matrix;
  45465. protected _projectionTextureLightNear: number;
  45466. /**
  45467. * Gets the near clip of the Spotlight for texture projection.
  45468. */
  45469. /**
  45470. * Sets the near clip of the Spotlight for texture projection.
  45471. */
  45472. projectionTextureLightNear: number;
  45473. protected _projectionTextureLightFar: number;
  45474. /**
  45475. * Gets the far clip of the Spotlight for texture projection.
  45476. */
  45477. /**
  45478. * Sets the far clip of the Spotlight for texture projection.
  45479. */
  45480. projectionTextureLightFar: number;
  45481. protected _projectionTextureUpDirection: Vector3;
  45482. /**
  45483. * Gets the Up vector of the Spotlight for texture projection.
  45484. */
  45485. /**
  45486. * Sets the Up vector of the Spotlight for texture projection.
  45487. */
  45488. projectionTextureUpDirection: Vector3;
  45489. private _projectionTexture;
  45490. /**
  45491. * Gets the projection texture of the light.
  45492. */
  45493. /**
  45494. * Sets the projection texture of the light.
  45495. */
  45496. projectionTexture: Nullable<BaseTexture>;
  45497. private _projectionTextureViewLightDirty;
  45498. private _projectionTextureProjectionLightDirty;
  45499. private _projectionTextureDirty;
  45500. private _projectionTextureViewTargetVector;
  45501. private _projectionTextureViewLightMatrix;
  45502. private _projectionTextureProjectionLightMatrix;
  45503. private _projectionTextureScalingMatrix;
  45504. /**
  45505. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45506. * It can cast shadows.
  45507. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45508. * @param name The light friendly name
  45509. * @param position The position of the spot light in the scene
  45510. * @param direction The direction of the light in the scene
  45511. * @param angle The cone angle of the light in Radians
  45512. * @param exponent The light decay speed with the distance from the emission spot
  45513. * @param scene The scene the lights belongs to
  45514. */
  45515. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45516. /**
  45517. * Returns the string "SpotLight".
  45518. * @returns the class name
  45519. */
  45520. getClassName(): string;
  45521. /**
  45522. * Returns the integer 2.
  45523. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45524. */
  45525. getTypeID(): number;
  45526. /**
  45527. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45528. */
  45529. protected _setDirection(value: Vector3): void;
  45530. /**
  45531. * Overrides the position setter to recompute the projection texture view light Matrix.
  45532. */
  45533. protected _setPosition(value: Vector3): void;
  45534. /**
  45535. * 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.
  45536. * Returns the SpotLight.
  45537. */
  45538. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45539. protected _computeProjectionTextureViewLightMatrix(): void;
  45540. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45541. /**
  45542. * Main function for light texture projection matrix computing.
  45543. */
  45544. protected _computeProjectionTextureMatrix(): void;
  45545. protected _buildUniformLayout(): void;
  45546. private _computeAngleValues;
  45547. /**
  45548. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45549. * @param effect The effect to update
  45550. * @param lightIndex The index of the light in the effect to update
  45551. * @returns The spot light
  45552. */
  45553. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45554. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  45555. /**
  45556. * Disposes the light and the associated resources.
  45557. */
  45558. dispose(): void;
  45559. /**
  45560. * Prepares the list of defines specific to the light type.
  45561. * @param defines the list of defines
  45562. * @param lightIndex defines the index of the light for the effect
  45563. */
  45564. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45565. }
  45566. }
  45567. declare module BABYLON {
  45568. /**
  45569. * Gizmo that enables viewing a light
  45570. */
  45571. export class LightGizmo extends Gizmo {
  45572. private _lightMesh;
  45573. private _material;
  45574. private cachedPosition;
  45575. private cachedForward;
  45576. /**
  45577. * Creates a LightGizmo
  45578. * @param gizmoLayer The utility layer the gizmo will be added to
  45579. */
  45580. constructor(gizmoLayer?: UtilityLayerRenderer);
  45581. private _light;
  45582. /**
  45583. * The light that the gizmo is attached to
  45584. */
  45585. light: Nullable<Light>;
  45586. /**
  45587. * Gets the material used to render the light gizmo
  45588. */
  45589. readonly material: StandardMaterial;
  45590. /**
  45591. * @hidden
  45592. * Updates the gizmo to match the attached mesh's position/rotation
  45593. */
  45594. protected _update(): void;
  45595. private static _Scale;
  45596. /**
  45597. * Creates the lines for a light mesh
  45598. */
  45599. private static _createLightLines;
  45600. /**
  45601. * Disposes of the light gizmo
  45602. */
  45603. dispose(): void;
  45604. private static _CreateHemisphericLightMesh;
  45605. private static _CreatePointLightMesh;
  45606. private static _CreateSpotLightMesh;
  45607. private static _CreateDirectionalLightMesh;
  45608. }
  45609. }
  45610. declare module BABYLON {
  45611. /** @hidden */
  45612. export var backgroundFragmentDeclaration: {
  45613. name: string;
  45614. shader: string;
  45615. };
  45616. }
  45617. declare module BABYLON {
  45618. /** @hidden */
  45619. export var backgroundUboDeclaration: {
  45620. name: string;
  45621. shader: string;
  45622. };
  45623. }
  45624. declare module BABYLON {
  45625. /** @hidden */
  45626. export var backgroundPixelShader: {
  45627. name: string;
  45628. shader: string;
  45629. };
  45630. }
  45631. declare module BABYLON {
  45632. /** @hidden */
  45633. export var backgroundVertexDeclaration: {
  45634. name: string;
  45635. shader: string;
  45636. };
  45637. }
  45638. declare module BABYLON {
  45639. /** @hidden */
  45640. export var backgroundVertexShader: {
  45641. name: string;
  45642. shader: string;
  45643. };
  45644. }
  45645. declare module BABYLON {
  45646. /**
  45647. * Background material used to create an efficient environement around your scene.
  45648. */
  45649. export class BackgroundMaterial extends PushMaterial {
  45650. /**
  45651. * Standard reflectance value at parallel view angle.
  45652. */
  45653. static StandardReflectance0: number;
  45654. /**
  45655. * Standard reflectance value at grazing angle.
  45656. */
  45657. static StandardReflectance90: number;
  45658. protected _primaryColor: Color3;
  45659. /**
  45660. * Key light Color (multiply against the environement texture)
  45661. */
  45662. primaryColor: Color3;
  45663. protected __perceptualColor: Nullable<Color3>;
  45664. /**
  45665. * Experimental Internal Use Only.
  45666. *
  45667. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45668. * This acts as a helper to set the primary color to a more "human friendly" value.
  45669. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45670. * output color as close as possible from the chosen value.
  45671. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45672. * part of lighting setup.)
  45673. */
  45674. _perceptualColor: Nullable<Color3>;
  45675. protected _primaryColorShadowLevel: float;
  45676. /**
  45677. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45678. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45679. */
  45680. primaryColorShadowLevel: float;
  45681. protected _primaryColorHighlightLevel: float;
  45682. /**
  45683. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45684. * The primary color is used at the level chosen to define what the white area would look.
  45685. */
  45686. primaryColorHighlightLevel: float;
  45687. protected _reflectionTexture: Nullable<BaseTexture>;
  45688. /**
  45689. * Reflection Texture used in the material.
  45690. * Should be author in a specific way for the best result (refer to the documentation).
  45691. */
  45692. reflectionTexture: Nullable<BaseTexture>;
  45693. protected _reflectionBlur: float;
  45694. /**
  45695. * Reflection Texture level of blur.
  45696. *
  45697. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45698. * texture twice.
  45699. */
  45700. reflectionBlur: float;
  45701. protected _diffuseTexture: Nullable<BaseTexture>;
  45702. /**
  45703. * Diffuse Texture used in the material.
  45704. * Should be author in a specific way for the best result (refer to the documentation).
  45705. */
  45706. diffuseTexture: Nullable<BaseTexture>;
  45707. protected _shadowLights: Nullable<IShadowLight[]>;
  45708. /**
  45709. * Specify the list of lights casting shadow on the material.
  45710. * All scene shadow lights will be included if null.
  45711. */
  45712. shadowLights: Nullable<IShadowLight[]>;
  45713. protected _shadowLevel: float;
  45714. /**
  45715. * Helps adjusting the shadow to a softer level if required.
  45716. * 0 means black shadows and 1 means no shadows.
  45717. */
  45718. shadowLevel: float;
  45719. protected _sceneCenter: Vector3;
  45720. /**
  45721. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45722. * It is usually zero but might be interesting to modify according to your setup.
  45723. */
  45724. sceneCenter: Vector3;
  45725. protected _opacityFresnel: boolean;
  45726. /**
  45727. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45728. * This helps ensuring a nice transition when the camera goes under the ground.
  45729. */
  45730. opacityFresnel: boolean;
  45731. protected _reflectionFresnel: boolean;
  45732. /**
  45733. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45734. * This helps adding a mirror texture on the ground.
  45735. */
  45736. reflectionFresnel: boolean;
  45737. protected _reflectionFalloffDistance: number;
  45738. /**
  45739. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45740. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45741. */
  45742. reflectionFalloffDistance: number;
  45743. protected _reflectionAmount: number;
  45744. /**
  45745. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45746. */
  45747. reflectionAmount: number;
  45748. protected _reflectionReflectance0: number;
  45749. /**
  45750. * This specifies the weight of the reflection at grazing angle.
  45751. */
  45752. reflectionReflectance0: number;
  45753. protected _reflectionReflectance90: number;
  45754. /**
  45755. * This specifies the weight of the reflection at a perpendicular point of view.
  45756. */
  45757. reflectionReflectance90: number;
  45758. /**
  45759. * Sets the reflection reflectance fresnel values according to the default standard
  45760. * empirically know to work well :-)
  45761. */
  45762. reflectionStandardFresnelWeight: number;
  45763. protected _useRGBColor: boolean;
  45764. /**
  45765. * Helps to directly use the maps channels instead of their level.
  45766. */
  45767. useRGBColor: boolean;
  45768. protected _enableNoise: boolean;
  45769. /**
  45770. * This helps reducing the banding effect that could occur on the background.
  45771. */
  45772. enableNoise: boolean;
  45773. /**
  45774. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45775. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45776. * Recommended to be keep at 1.0 except for special cases.
  45777. */
  45778. fovMultiplier: number;
  45779. private _fovMultiplier;
  45780. /**
  45781. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45782. */
  45783. useEquirectangularFOV: boolean;
  45784. private _maxSimultaneousLights;
  45785. /**
  45786. * Number of Simultaneous lights allowed on the material.
  45787. */
  45788. maxSimultaneousLights: int;
  45789. /**
  45790. * Default configuration related to image processing available in the Background Material.
  45791. */
  45792. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45793. /**
  45794. * Keep track of the image processing observer to allow dispose and replace.
  45795. */
  45796. private _imageProcessingObserver;
  45797. /**
  45798. * Attaches a new image processing configuration to the PBR Material.
  45799. * @param configuration (if null the scene configuration will be use)
  45800. */
  45801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45802. /**
  45803. * Gets the image processing configuration used either in this material.
  45804. */
  45805. /**
  45806. * Sets the Default image processing configuration used either in the this material.
  45807. *
  45808. * If sets to null, the scene one is in use.
  45809. */
  45810. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45811. /**
  45812. * Gets wether the color curves effect is enabled.
  45813. */
  45814. /**
  45815. * Sets wether the color curves effect is enabled.
  45816. */
  45817. cameraColorCurvesEnabled: boolean;
  45818. /**
  45819. * Gets wether the color grading effect is enabled.
  45820. */
  45821. /**
  45822. * Gets wether the color grading effect is enabled.
  45823. */
  45824. cameraColorGradingEnabled: boolean;
  45825. /**
  45826. * Gets wether tonemapping is enabled or not.
  45827. */
  45828. /**
  45829. * Sets wether tonemapping is enabled or not
  45830. */
  45831. cameraToneMappingEnabled: boolean;
  45832. /**
  45833. * The camera exposure used on this material.
  45834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45835. * This corresponds to a photographic exposure.
  45836. */
  45837. /**
  45838. * The camera exposure used on this material.
  45839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45840. * This corresponds to a photographic exposure.
  45841. */
  45842. cameraExposure: float;
  45843. /**
  45844. * Gets The camera contrast used on this material.
  45845. */
  45846. /**
  45847. * Sets The camera contrast used on this material.
  45848. */
  45849. cameraContrast: float;
  45850. /**
  45851. * Gets the Color Grading 2D Lookup Texture.
  45852. */
  45853. /**
  45854. * Sets the Color Grading 2D Lookup Texture.
  45855. */
  45856. cameraColorGradingTexture: Nullable<BaseTexture>;
  45857. /**
  45858. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45859. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45860. * 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;
  45861. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45862. */
  45863. /**
  45864. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45865. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45866. * 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;
  45867. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45868. */
  45869. cameraColorCurves: Nullable<ColorCurves>;
  45870. /**
  45871. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45872. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45873. */
  45874. switchToBGR: boolean;
  45875. private _renderTargets;
  45876. private _reflectionControls;
  45877. private _white;
  45878. private _primaryShadowColor;
  45879. private _primaryHighlightColor;
  45880. /**
  45881. * Instantiates a Background Material in the given scene
  45882. * @param name The friendly name of the material
  45883. * @param scene The scene to add the material to
  45884. */
  45885. constructor(name: string, scene: Scene);
  45886. /**
  45887. * Gets a boolean indicating that current material needs to register RTT
  45888. */
  45889. readonly hasRenderTargetTextures: boolean;
  45890. /**
  45891. * The entire material has been created in order to prevent overdraw.
  45892. * @returns false
  45893. */
  45894. needAlphaTesting(): boolean;
  45895. /**
  45896. * The entire material has been created in order to prevent overdraw.
  45897. * @returns true if blending is enable
  45898. */
  45899. needAlphaBlending(): boolean;
  45900. /**
  45901. * Checks wether the material is ready to be rendered for a given mesh.
  45902. * @param mesh The mesh to render
  45903. * @param subMesh The submesh to check against
  45904. * @param useInstances Specify wether or not the material is used with instances
  45905. * @returns true if all the dependencies are ready (Textures, Effects...)
  45906. */
  45907. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45908. /**
  45909. * Compute the primary color according to the chosen perceptual color.
  45910. */
  45911. private _computePrimaryColorFromPerceptualColor;
  45912. /**
  45913. * Compute the highlights and shadow colors according to their chosen levels.
  45914. */
  45915. private _computePrimaryColors;
  45916. /**
  45917. * Build the uniform buffer used in the material.
  45918. */
  45919. buildUniformLayout(): void;
  45920. /**
  45921. * Unbind the material.
  45922. */
  45923. unbind(): void;
  45924. /**
  45925. * Bind only the world matrix to the material.
  45926. * @param world The world matrix to bind.
  45927. */
  45928. bindOnlyWorldMatrix(world: Matrix): void;
  45929. /**
  45930. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45931. * @param world The world matrix to bind.
  45932. * @param subMesh The submesh to bind for.
  45933. */
  45934. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45935. /**
  45936. * Checks to see if a texture is used in the material.
  45937. * @param texture - Base texture to use.
  45938. * @returns - Boolean specifying if a texture is used in the material.
  45939. */
  45940. hasTexture(texture: BaseTexture): boolean;
  45941. /**
  45942. * Dispose the material.
  45943. * @param forceDisposeEffect Force disposal of the associated effect.
  45944. * @param forceDisposeTextures Force disposal of the associated textures.
  45945. */
  45946. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45947. /**
  45948. * Clones the material.
  45949. * @param name The cloned name.
  45950. * @returns The cloned material.
  45951. */
  45952. clone(name: string): BackgroundMaterial;
  45953. /**
  45954. * Serializes the current material to its JSON representation.
  45955. * @returns The JSON representation.
  45956. */
  45957. serialize(): any;
  45958. /**
  45959. * Gets the class name of the material
  45960. * @returns "BackgroundMaterial"
  45961. */
  45962. getClassName(): string;
  45963. /**
  45964. * Parse a JSON input to create back a background material.
  45965. * @param source The JSON data to parse
  45966. * @param scene The scene to create the parsed material in
  45967. * @param rootUrl The root url of the assets the material depends upon
  45968. * @returns the instantiated BackgroundMaterial.
  45969. */
  45970. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45971. }
  45972. }
  45973. declare module BABYLON {
  45974. /**
  45975. * Represents the different options available during the creation of
  45976. * a Environment helper.
  45977. *
  45978. * This can control the default ground, skybox and image processing setup of your scene.
  45979. */
  45980. export interface IEnvironmentHelperOptions {
  45981. /**
  45982. * Specifies wether or not to create a ground.
  45983. * True by default.
  45984. */
  45985. createGround: boolean;
  45986. /**
  45987. * Specifies the ground size.
  45988. * 15 by default.
  45989. */
  45990. groundSize: number;
  45991. /**
  45992. * The texture used on the ground for the main color.
  45993. * Comes from the BabylonJS CDN by default.
  45994. *
  45995. * Remarks: Can be either a texture or a url.
  45996. */
  45997. groundTexture: string | BaseTexture;
  45998. /**
  45999. * The color mixed in the ground texture by default.
  46000. * BabylonJS clearColor by default.
  46001. */
  46002. groundColor: Color3;
  46003. /**
  46004. * Specifies the ground opacity.
  46005. * 1 by default.
  46006. */
  46007. groundOpacity: number;
  46008. /**
  46009. * Enables the ground to receive shadows.
  46010. * True by default.
  46011. */
  46012. enableGroundShadow: boolean;
  46013. /**
  46014. * Helps preventing the shadow to be fully black on the ground.
  46015. * 0.5 by default.
  46016. */
  46017. groundShadowLevel: number;
  46018. /**
  46019. * Creates a mirror texture attach to the ground.
  46020. * false by default.
  46021. */
  46022. enableGroundMirror: boolean;
  46023. /**
  46024. * Specifies the ground mirror size ratio.
  46025. * 0.3 by default as the default kernel is 64.
  46026. */
  46027. groundMirrorSizeRatio: number;
  46028. /**
  46029. * Specifies the ground mirror blur kernel size.
  46030. * 64 by default.
  46031. */
  46032. groundMirrorBlurKernel: number;
  46033. /**
  46034. * Specifies the ground mirror visibility amount.
  46035. * 1 by default
  46036. */
  46037. groundMirrorAmount: number;
  46038. /**
  46039. * Specifies the ground mirror reflectance weight.
  46040. * This uses the standard weight of the background material to setup the fresnel effect
  46041. * of the mirror.
  46042. * 1 by default.
  46043. */
  46044. groundMirrorFresnelWeight: number;
  46045. /**
  46046. * Specifies the ground mirror Falloff distance.
  46047. * This can helps reducing the size of the reflection.
  46048. * 0 by Default.
  46049. */
  46050. groundMirrorFallOffDistance: number;
  46051. /**
  46052. * Specifies the ground mirror texture type.
  46053. * Unsigned Int by Default.
  46054. */
  46055. groundMirrorTextureType: number;
  46056. /**
  46057. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46058. * the shown objects.
  46059. */
  46060. groundYBias: number;
  46061. /**
  46062. * Specifies wether or not to create a skybox.
  46063. * True by default.
  46064. */
  46065. createSkybox: boolean;
  46066. /**
  46067. * Specifies the skybox size.
  46068. * 20 by default.
  46069. */
  46070. skyboxSize: number;
  46071. /**
  46072. * The texture used on the skybox for the main color.
  46073. * Comes from the BabylonJS CDN by default.
  46074. *
  46075. * Remarks: Can be either a texture or a url.
  46076. */
  46077. skyboxTexture: string | BaseTexture;
  46078. /**
  46079. * The color mixed in the skybox texture by default.
  46080. * BabylonJS clearColor by default.
  46081. */
  46082. skyboxColor: Color3;
  46083. /**
  46084. * The background rotation around the Y axis of the scene.
  46085. * This helps aligning the key lights of your scene with the background.
  46086. * 0 by default.
  46087. */
  46088. backgroundYRotation: number;
  46089. /**
  46090. * Compute automatically the size of the elements to best fit with the scene.
  46091. */
  46092. sizeAuto: boolean;
  46093. /**
  46094. * Default position of the rootMesh if autoSize is not true.
  46095. */
  46096. rootPosition: Vector3;
  46097. /**
  46098. * Sets up the image processing in the scene.
  46099. * true by default.
  46100. */
  46101. setupImageProcessing: boolean;
  46102. /**
  46103. * The texture used as your environment texture in the scene.
  46104. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46105. *
  46106. * Remarks: Can be either a texture or a url.
  46107. */
  46108. environmentTexture: string | BaseTexture;
  46109. /**
  46110. * The value of the exposure to apply to the scene.
  46111. * 0.6 by default if setupImageProcessing is true.
  46112. */
  46113. cameraExposure: number;
  46114. /**
  46115. * The value of the contrast to apply to the scene.
  46116. * 1.6 by default if setupImageProcessing is true.
  46117. */
  46118. cameraContrast: number;
  46119. /**
  46120. * Specifies wether or not tonemapping should be enabled in the scene.
  46121. * true by default if setupImageProcessing is true.
  46122. */
  46123. toneMappingEnabled: boolean;
  46124. }
  46125. /**
  46126. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46127. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46128. * It also helps with the default setup of your imageProcessing configuration.
  46129. */
  46130. export class EnvironmentHelper {
  46131. /**
  46132. * Default ground texture URL.
  46133. */
  46134. private static _groundTextureCDNUrl;
  46135. /**
  46136. * Default skybox texture URL.
  46137. */
  46138. private static _skyboxTextureCDNUrl;
  46139. /**
  46140. * Default environment texture URL.
  46141. */
  46142. private static _environmentTextureCDNUrl;
  46143. /**
  46144. * Creates the default options for the helper.
  46145. */
  46146. private static _getDefaultOptions;
  46147. private _rootMesh;
  46148. /**
  46149. * Gets the root mesh created by the helper.
  46150. */
  46151. readonly rootMesh: Mesh;
  46152. private _skybox;
  46153. /**
  46154. * Gets the skybox created by the helper.
  46155. */
  46156. readonly skybox: Nullable<Mesh>;
  46157. private _skyboxTexture;
  46158. /**
  46159. * Gets the skybox texture created by the helper.
  46160. */
  46161. readonly skyboxTexture: Nullable<BaseTexture>;
  46162. private _skyboxMaterial;
  46163. /**
  46164. * Gets the skybox material created by the helper.
  46165. */
  46166. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46167. private _ground;
  46168. /**
  46169. * Gets the ground mesh created by the helper.
  46170. */
  46171. readonly ground: Nullable<Mesh>;
  46172. private _groundTexture;
  46173. /**
  46174. * Gets the ground texture created by the helper.
  46175. */
  46176. readonly groundTexture: Nullable<BaseTexture>;
  46177. private _groundMirror;
  46178. /**
  46179. * Gets the ground mirror created by the helper.
  46180. */
  46181. readonly groundMirror: Nullable<MirrorTexture>;
  46182. /**
  46183. * Gets the ground mirror render list to helps pushing the meshes
  46184. * you wish in the ground reflection.
  46185. */
  46186. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46187. private _groundMaterial;
  46188. /**
  46189. * Gets the ground material created by the helper.
  46190. */
  46191. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46192. /**
  46193. * Stores the creation options.
  46194. */
  46195. private readonly _scene;
  46196. private _options;
  46197. /**
  46198. * This observable will be notified with any error during the creation of the environment,
  46199. * mainly texture creation errors.
  46200. */
  46201. onErrorObservable: Observable<{
  46202. message?: string;
  46203. exception?: any;
  46204. }>;
  46205. /**
  46206. * constructor
  46207. * @param options Defines the options we want to customize the helper
  46208. * @param scene The scene to add the material to
  46209. */
  46210. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46211. /**
  46212. * Updates the background according to the new options
  46213. * @param options
  46214. */
  46215. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46216. /**
  46217. * Sets the primary color of all the available elements.
  46218. * @param color the main color to affect to the ground and the background
  46219. */
  46220. setMainColor(color: Color3): void;
  46221. /**
  46222. * Setup the image processing according to the specified options.
  46223. */
  46224. private _setupImageProcessing;
  46225. /**
  46226. * Setup the environment texture according to the specified options.
  46227. */
  46228. private _setupEnvironmentTexture;
  46229. /**
  46230. * Setup the background according to the specified options.
  46231. */
  46232. private _setupBackground;
  46233. /**
  46234. * Get the scene sizes according to the setup.
  46235. */
  46236. private _getSceneSize;
  46237. /**
  46238. * Setup the ground according to the specified options.
  46239. */
  46240. private _setupGround;
  46241. /**
  46242. * Setup the ground material according to the specified options.
  46243. */
  46244. private _setupGroundMaterial;
  46245. /**
  46246. * Setup the ground diffuse texture according to the specified options.
  46247. */
  46248. private _setupGroundDiffuseTexture;
  46249. /**
  46250. * Setup the ground mirror texture according to the specified options.
  46251. */
  46252. private _setupGroundMirrorTexture;
  46253. /**
  46254. * Setup the ground to receive the mirror texture.
  46255. */
  46256. private _setupMirrorInGroundMaterial;
  46257. /**
  46258. * Setup the skybox according to the specified options.
  46259. */
  46260. private _setupSkybox;
  46261. /**
  46262. * Setup the skybox material according to the specified options.
  46263. */
  46264. private _setupSkyboxMaterial;
  46265. /**
  46266. * Setup the skybox reflection texture according to the specified options.
  46267. */
  46268. private _setupSkyboxReflectionTexture;
  46269. private _errorHandler;
  46270. /**
  46271. * Dispose all the elements created by the Helper.
  46272. */
  46273. dispose(): void;
  46274. }
  46275. }
  46276. declare module BABYLON {
  46277. /**
  46278. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46279. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46280. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46281. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46282. */
  46283. export class PhotoDome extends TransformNode {
  46284. /**
  46285. * Define the image as a Monoscopic panoramic 360 image.
  46286. */
  46287. static readonly MODE_MONOSCOPIC: number;
  46288. /**
  46289. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46290. */
  46291. static readonly MODE_TOPBOTTOM: number;
  46292. /**
  46293. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46294. */
  46295. static readonly MODE_SIDEBYSIDE: number;
  46296. private _useDirectMapping;
  46297. /**
  46298. * The texture being displayed on the sphere
  46299. */
  46300. protected _photoTexture: Texture;
  46301. /**
  46302. * Gets or sets the texture being displayed on the sphere
  46303. */
  46304. photoTexture: Texture;
  46305. /**
  46306. * Observable raised when an error occured while loading the 360 image
  46307. */
  46308. onLoadErrorObservable: Observable<string>;
  46309. /**
  46310. * The skybox material
  46311. */
  46312. protected _material: BackgroundMaterial;
  46313. /**
  46314. * The surface used for the skybox
  46315. */
  46316. protected _mesh: Mesh;
  46317. /**
  46318. * Gets the mesh used for the skybox.
  46319. */
  46320. readonly mesh: Mesh;
  46321. /**
  46322. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46323. * Also see the options.resolution property.
  46324. */
  46325. fovMultiplier: number;
  46326. private _imageMode;
  46327. /**
  46328. * Gets or set the current video mode for the video. It can be:
  46329. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46330. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46331. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46332. */
  46333. imageMode: number;
  46334. /**
  46335. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46336. * @param name Element's name, child elements will append suffixes for their own names.
  46337. * @param urlsOfPhoto defines the url of the photo to display
  46338. * @param options defines an object containing optional or exposed sub element properties
  46339. * @param onError defines a callback called when an error occured while loading the texture
  46340. */
  46341. constructor(name: string, urlOfPhoto: string, options: {
  46342. resolution?: number;
  46343. size?: number;
  46344. useDirectMapping?: boolean;
  46345. faceForward?: boolean;
  46346. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46347. private _onBeforeCameraRenderObserver;
  46348. private _changeImageMode;
  46349. /**
  46350. * Releases resources associated with this node.
  46351. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46352. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46353. */
  46354. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46355. }
  46356. }
  46357. declare module BABYLON {
  46358. /**
  46359. * Class used to host RGBD texture specific utilities
  46360. */
  46361. export class RGBDTextureTools {
  46362. /**
  46363. * Expand the RGBD Texture from RGBD to Half Float if possible.
  46364. * @param texture the texture to expand.
  46365. */
  46366. static ExpandRGBDTexture(texture: Texture): void;
  46367. }
  46368. }
  46369. declare module BABYLON {
  46370. /**
  46371. * Class used to host texture specific utilities
  46372. */
  46373. export class BRDFTextureTools {
  46374. /**
  46375. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46376. * @param scene defines the hosting scene
  46377. * @returns the environment BRDF texture
  46378. */
  46379. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46380. private static _environmentBRDFBase64Texture;
  46381. }
  46382. }
  46383. declare module BABYLON {
  46384. /**
  46385. * @hidden
  46386. */
  46387. export interface IMaterialClearCoatDefines {
  46388. CLEARCOAT: boolean;
  46389. CLEARCOAT_DEFAULTIOR: boolean;
  46390. CLEARCOAT_TEXTURE: boolean;
  46391. CLEARCOAT_TEXTUREDIRECTUV: number;
  46392. CLEARCOAT_BUMP: boolean;
  46393. CLEARCOAT_BUMPDIRECTUV: number;
  46394. CLEARCOAT_TINT: boolean;
  46395. CLEARCOAT_TINT_TEXTURE: boolean;
  46396. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46397. /** @hidden */
  46398. _areTexturesDirty: boolean;
  46399. }
  46400. /**
  46401. * Define the code related to the clear coat parameters of the pbr material.
  46402. */
  46403. export class PBRClearCoatConfiguration {
  46404. /**
  46405. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46406. * The default fits with a polyurethane material.
  46407. */
  46408. private static readonly _DefaultIndexOfRefraction;
  46409. private _isEnabled;
  46410. /**
  46411. * Defines if the clear coat is enabled in the material.
  46412. */
  46413. isEnabled: boolean;
  46414. /**
  46415. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46416. */
  46417. intensity: number;
  46418. /**
  46419. * Defines the clear coat layer roughness.
  46420. */
  46421. roughness: number;
  46422. private _indexOfRefraction;
  46423. /**
  46424. * Defines the index of refraction of the clear coat.
  46425. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46426. * The default fits with a polyurethane material.
  46427. * Changing the default value is more performance intensive.
  46428. */
  46429. indexOfRefraction: number;
  46430. private _texture;
  46431. /**
  46432. * Stores the clear coat values in a texture.
  46433. */
  46434. texture: Nullable<BaseTexture>;
  46435. private _bumpTexture;
  46436. /**
  46437. * Define the clear coat specific bump texture.
  46438. */
  46439. bumpTexture: Nullable<BaseTexture>;
  46440. private _isTintEnabled;
  46441. /**
  46442. * Defines if the clear coat tint is enabled in the material.
  46443. */
  46444. isTintEnabled: boolean;
  46445. /**
  46446. * Defines the clear coat tint of the material.
  46447. * This is only use if tint is enabled
  46448. */
  46449. tintColor: Color3;
  46450. /**
  46451. * Defines the distance at which the tint color should be found in the
  46452. * clear coat media.
  46453. * This is only use if tint is enabled
  46454. */
  46455. tintColorAtDistance: number;
  46456. /**
  46457. * Defines the clear coat layer thickness.
  46458. * This is only use if tint is enabled
  46459. */
  46460. tintThickness: number;
  46461. private _tintTexture;
  46462. /**
  46463. * Stores the clear tint values in a texture.
  46464. * rgb is tint
  46465. * a is a thickness factor
  46466. */
  46467. tintTexture: Nullable<BaseTexture>;
  46468. /** @hidden */
  46469. private _internalMarkAllSubMeshesAsTexturesDirty;
  46470. /** @hidden */
  46471. _markAllSubMeshesAsTexturesDirty(): void;
  46472. /**
  46473. * Instantiate a new istance of clear coat configuration.
  46474. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46475. */
  46476. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46477. /**
  46478. * Gets wehter the submesh is ready to be used or not.
  46479. * @param defines the list of "defines" to update.
  46480. * @param scene defines the scene the material belongs to.
  46481. * @param engine defines the engine the material belongs to.
  46482. * @param disableBumpMap defines wether the material disables bump or not.
  46483. * @returns - boolean indicating that the submesh is ready or not.
  46484. */
  46485. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46486. /**
  46487. * Checks to see if a texture is used in the material.
  46488. * @param defines the list of "defines" to update.
  46489. * @param scene defines the scene to the material belongs to.
  46490. */
  46491. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46492. /**
  46493. * Binds the material data.
  46494. * @param uniformBuffer defines the Uniform buffer to fill in.
  46495. * @param scene defines the scene the material belongs to.
  46496. * @param engine defines the engine the material belongs to.
  46497. * @param disableBumpMap defines wether the material disables bump or not.
  46498. * @param isFrozen defines wether the material is frozen or not.
  46499. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46500. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46501. */
  46502. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46503. /**
  46504. * Checks to see if a texture is used in the material.
  46505. * @param texture - Base texture to use.
  46506. * @returns - Boolean specifying if a texture is used in the material.
  46507. */
  46508. hasTexture(texture: BaseTexture): boolean;
  46509. /**
  46510. * Returns an array of the actively used textures.
  46511. * @param activeTextures Array of BaseTextures
  46512. */
  46513. getActiveTextures(activeTextures: BaseTexture[]): void;
  46514. /**
  46515. * Returns the animatable textures.
  46516. * @param animatables Array of animatable textures.
  46517. */
  46518. getAnimatables(animatables: IAnimatable[]): void;
  46519. /**
  46520. * Disposes the resources of the material.
  46521. * @param forceDisposeTextures - Forces the disposal of all textures.
  46522. */
  46523. dispose(forceDisposeTextures?: boolean): void;
  46524. /**
  46525. * Get the current class name of the texture useful for serialization or dynamic coding.
  46526. * @returns "PBRClearCoatConfiguration"
  46527. */
  46528. getClassName(): string;
  46529. /**
  46530. * Add fallbacks to the effect fallbacks list.
  46531. * @param defines defines the Base texture to use.
  46532. * @param fallbacks defines the current fallback list.
  46533. * @param currentRank defines the current fallback rank.
  46534. * @returns the new fallback rank.
  46535. */
  46536. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46537. /**
  46538. * Add the required uniforms to the current list.
  46539. * @param uniforms defines the current uniform list.
  46540. */
  46541. static AddUniforms(uniforms: string[]): void;
  46542. /**
  46543. * Add the required samplers to the current list.
  46544. * @param samplers defines the current sampler list.
  46545. */
  46546. static AddSamplers(samplers: string[]): void;
  46547. /**
  46548. * Add the required uniforms to the current buffer.
  46549. * @param uniformBuffer defines the current uniform buffer.
  46550. */
  46551. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46552. /**
  46553. * Makes a duplicate of the current configuration into another one.
  46554. * @param clearCoatConfiguration define the config where to copy the info
  46555. */
  46556. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46557. /**
  46558. * Serializes this clear coat configuration.
  46559. * @returns - An object with the serialized config.
  46560. */
  46561. serialize(): any;
  46562. /**
  46563. * Parses a anisotropy Configuration from a serialized object.
  46564. * @param source - Serialized object.
  46565. * @param scene Defines the scene we are parsing for
  46566. * @param rootUrl Defines the rootUrl to load from
  46567. */
  46568. parse(source: any, scene: Scene, rootUrl: string): void;
  46569. }
  46570. }
  46571. declare module BABYLON {
  46572. /**
  46573. * @hidden
  46574. */
  46575. export interface IMaterialAnisotropicDefines {
  46576. ANISOTROPIC: boolean;
  46577. ANISOTROPIC_TEXTURE: boolean;
  46578. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46579. MAINUV1: boolean;
  46580. _areTexturesDirty: boolean;
  46581. _needUVs: boolean;
  46582. }
  46583. /**
  46584. * Define the code related to the anisotropic parameters of the pbr material.
  46585. */
  46586. export class PBRAnisotropicConfiguration {
  46587. private _isEnabled;
  46588. /**
  46589. * Defines if the anisotropy is enabled in the material.
  46590. */
  46591. isEnabled: boolean;
  46592. /**
  46593. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46594. */
  46595. intensity: number;
  46596. /**
  46597. * Defines if the effect is along the tangents, bitangents or in between.
  46598. * By default, the effect is "strectching" the highlights along the tangents.
  46599. */
  46600. direction: Vector2;
  46601. private _texture;
  46602. /**
  46603. * Stores the anisotropy values in a texture.
  46604. * rg is direction (like normal from -1 to 1)
  46605. * b is a intensity
  46606. */
  46607. texture: Nullable<BaseTexture>;
  46608. /** @hidden */
  46609. private _internalMarkAllSubMeshesAsTexturesDirty;
  46610. /** @hidden */
  46611. _markAllSubMeshesAsTexturesDirty(): void;
  46612. /**
  46613. * Instantiate a new istance of anisotropy configuration.
  46614. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46615. */
  46616. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46617. /**
  46618. * Specifies that the submesh is ready to be used.
  46619. * @param defines the list of "defines" to update.
  46620. * @param scene defines the scene the material belongs to.
  46621. * @returns - boolean indicating that the submesh is ready or not.
  46622. */
  46623. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46624. /**
  46625. * Checks to see if a texture is used in the material.
  46626. * @param defines the list of "defines" to update.
  46627. * @param mesh the mesh we are preparing the defines for.
  46628. * @param scene defines the scene the material belongs to.
  46629. */
  46630. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46631. /**
  46632. * Binds the material data.
  46633. * @param uniformBuffer defines the Uniform buffer to fill in.
  46634. * @param scene defines the scene the material belongs to.
  46635. * @param isFrozen defines wether the material is frozen or not.
  46636. */
  46637. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46638. /**
  46639. * Checks to see if a texture is used in the material.
  46640. * @param texture - Base texture to use.
  46641. * @returns - Boolean specifying if a texture is used in the material.
  46642. */
  46643. hasTexture(texture: BaseTexture): boolean;
  46644. /**
  46645. * Returns an array of the actively used textures.
  46646. * @param activeTextures Array of BaseTextures
  46647. */
  46648. getActiveTextures(activeTextures: BaseTexture[]): void;
  46649. /**
  46650. * Returns the animatable textures.
  46651. * @param animatables Array of animatable textures.
  46652. */
  46653. getAnimatables(animatables: IAnimatable[]): void;
  46654. /**
  46655. * Disposes the resources of the material.
  46656. * @param forceDisposeTextures - Forces the disposal of all textures.
  46657. */
  46658. dispose(forceDisposeTextures?: boolean): void;
  46659. /**
  46660. * Get the current class name of the texture useful for serialization or dynamic coding.
  46661. * @returns "PBRAnisotropicConfiguration"
  46662. */
  46663. getClassName(): string;
  46664. /**
  46665. * Add fallbacks to the effect fallbacks list.
  46666. * @param defines defines the Base texture to use.
  46667. * @param fallbacks defines the current fallback list.
  46668. * @param currentRank defines the current fallback rank.
  46669. * @returns the new fallback rank.
  46670. */
  46671. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46672. /**
  46673. * Add the required uniforms to the current list.
  46674. * @param uniforms defines the current uniform list.
  46675. */
  46676. static AddUniforms(uniforms: string[]): void;
  46677. /**
  46678. * Add the required uniforms to the current buffer.
  46679. * @param uniformBuffer defines the current uniform buffer.
  46680. */
  46681. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46682. /**
  46683. * Add the required samplers to the current list.
  46684. * @param samplers defines the current sampler list.
  46685. */
  46686. static AddSamplers(samplers: string[]): void;
  46687. /**
  46688. * Makes a duplicate of the current configuration into another one.
  46689. * @param anisotropicConfiguration define the config where to copy the info
  46690. */
  46691. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46692. /**
  46693. * Serializes this anisotropy configuration.
  46694. * @returns - An object with the serialized config.
  46695. */
  46696. serialize(): any;
  46697. /**
  46698. * Parses a anisotropy Configuration from a serialized object.
  46699. * @param source - Serialized object.
  46700. * @param scene Defines the scene we are parsing for
  46701. * @param rootUrl Defines the rootUrl to load from
  46702. */
  46703. parse(source: any, scene: Scene, rootUrl: string): void;
  46704. }
  46705. }
  46706. declare module BABYLON {
  46707. /**
  46708. * @hidden
  46709. */
  46710. export interface IMaterialBRDFDefines {
  46711. BRDF_V_HEIGHT_CORRELATED: boolean;
  46712. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46713. SPHERICAL_HARMONICS: boolean;
  46714. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46715. /** @hidden */
  46716. _areMiscDirty: boolean;
  46717. }
  46718. /**
  46719. * Define the code related to the BRDF parameters of the pbr material.
  46720. */
  46721. export class PBRBRDFConfiguration {
  46722. /**
  46723. * Default value used for the energy conservation.
  46724. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46725. */
  46726. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46727. /**
  46728. * Default value used for the Smith Visibility Height Correlated mode.
  46729. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46730. */
  46731. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46732. /**
  46733. * Default value used for the IBL diffuse part.
  46734. * This can help switching back to the polynomials mode globally which is a tiny bit
  46735. * less GPU intensive at the drawback of a lower quality.
  46736. */
  46737. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46738. /**
  46739. * Default value used for activating energy conservation for the specular workflow.
  46740. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46741. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46742. */
  46743. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46744. private _useEnergyConservation;
  46745. /**
  46746. * Defines if the material uses energy conservation.
  46747. */
  46748. useEnergyConservation: boolean;
  46749. private _useSmithVisibilityHeightCorrelated;
  46750. /**
  46751. * LEGACY Mode set to false
  46752. * Defines if the material uses height smith correlated visibility term.
  46753. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46754. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46755. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46756. * Not relying on height correlated will also disable energy conservation.
  46757. */
  46758. useSmithVisibilityHeightCorrelated: boolean;
  46759. private _useSphericalHarmonics;
  46760. /**
  46761. * LEGACY Mode set to false
  46762. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46763. * diffuse part of the IBL.
  46764. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46765. * to the ground truth.
  46766. */
  46767. useSphericalHarmonics: boolean;
  46768. private _useSpecularGlossinessInputEnergyConservation;
  46769. /**
  46770. * Defines if the material uses energy conservation, when the specular workflow is active.
  46771. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46772. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46773. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46774. */
  46775. useSpecularGlossinessInputEnergyConservation: boolean;
  46776. /** @hidden */
  46777. private _internalMarkAllSubMeshesAsMiscDirty;
  46778. /** @hidden */
  46779. _markAllSubMeshesAsMiscDirty(): void;
  46780. /**
  46781. * Instantiate a new istance of clear coat configuration.
  46782. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46783. */
  46784. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46785. /**
  46786. * Checks to see if a texture is used in the material.
  46787. * @param defines the list of "defines" to update.
  46788. */
  46789. prepareDefines(defines: IMaterialBRDFDefines): void;
  46790. /**
  46791. * Get the current class name of the texture useful for serialization or dynamic coding.
  46792. * @returns "PBRClearCoatConfiguration"
  46793. */
  46794. getClassName(): string;
  46795. /**
  46796. * Makes a duplicate of the current configuration into another one.
  46797. * @param brdfConfiguration define the config where to copy the info
  46798. */
  46799. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46800. /**
  46801. * Serializes this BRDF configuration.
  46802. * @returns - An object with the serialized config.
  46803. */
  46804. serialize(): any;
  46805. /**
  46806. * Parses a anisotropy Configuration from a serialized object.
  46807. * @param source - Serialized object.
  46808. * @param scene Defines the scene we are parsing for
  46809. * @param rootUrl Defines the rootUrl to load from
  46810. */
  46811. parse(source: any, scene: Scene, rootUrl: string): void;
  46812. }
  46813. }
  46814. declare module BABYLON {
  46815. /**
  46816. * @hidden
  46817. */
  46818. export interface IMaterialSheenDefines {
  46819. SHEEN: boolean;
  46820. SHEEN_TEXTURE: boolean;
  46821. SHEEN_TEXTUREDIRECTUV: number;
  46822. SHEEN_LINKWITHALBEDO: boolean;
  46823. /** @hidden */
  46824. _areTexturesDirty: boolean;
  46825. }
  46826. /**
  46827. * Define the code related to the Sheen parameters of the pbr material.
  46828. */
  46829. export class PBRSheenConfiguration {
  46830. private _isEnabled;
  46831. /**
  46832. * Defines if the material uses sheen.
  46833. */
  46834. isEnabled: boolean;
  46835. private _linkSheenWithAlbedo;
  46836. /**
  46837. * Defines if the sheen is linked to the sheen color.
  46838. */
  46839. linkSheenWithAlbedo: boolean;
  46840. /**
  46841. * Defines the sheen intensity.
  46842. */
  46843. intensity: number;
  46844. /**
  46845. * Defines the sheen color.
  46846. */
  46847. color: Color3;
  46848. private _texture;
  46849. /**
  46850. * Stores the sheen tint values in a texture.
  46851. * rgb is tint
  46852. * a is a intensity
  46853. */
  46854. texture: Nullable<BaseTexture>;
  46855. /** @hidden */
  46856. private _internalMarkAllSubMeshesAsTexturesDirty;
  46857. /** @hidden */
  46858. _markAllSubMeshesAsTexturesDirty(): void;
  46859. /**
  46860. * Instantiate a new istance of clear coat configuration.
  46861. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46862. */
  46863. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46864. /**
  46865. * Specifies that the submesh is ready to be used.
  46866. * @param defines the list of "defines" to update.
  46867. * @param scene defines the scene the material belongs to.
  46868. * @returns - boolean indicating that the submesh is ready or not.
  46869. */
  46870. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46871. /**
  46872. * Checks to see if a texture is used in the material.
  46873. * @param defines the list of "defines" to update.
  46874. * @param scene defines the scene the material belongs to.
  46875. */
  46876. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46877. /**
  46878. * Binds the material data.
  46879. * @param uniformBuffer defines the Uniform buffer to fill in.
  46880. * @param scene defines the scene the material belongs to.
  46881. * @param isFrozen defines wether the material is frozen or not.
  46882. */
  46883. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46884. /**
  46885. * Checks to see if a texture is used in the material.
  46886. * @param texture - Base texture to use.
  46887. * @returns - Boolean specifying if a texture is used in the material.
  46888. */
  46889. hasTexture(texture: BaseTexture): boolean;
  46890. /**
  46891. * Returns an array of the actively used textures.
  46892. * @param activeTextures Array of BaseTextures
  46893. */
  46894. getActiveTextures(activeTextures: BaseTexture[]): void;
  46895. /**
  46896. * Returns the animatable textures.
  46897. * @param animatables Array of animatable textures.
  46898. */
  46899. getAnimatables(animatables: IAnimatable[]): void;
  46900. /**
  46901. * Disposes the resources of the material.
  46902. * @param forceDisposeTextures - Forces the disposal of all textures.
  46903. */
  46904. dispose(forceDisposeTextures?: boolean): void;
  46905. /**
  46906. * Get the current class name of the texture useful for serialization or dynamic coding.
  46907. * @returns "PBRSheenConfiguration"
  46908. */
  46909. getClassName(): string;
  46910. /**
  46911. * Add fallbacks to the effect fallbacks list.
  46912. * @param defines defines the Base texture to use.
  46913. * @param fallbacks defines the current fallback list.
  46914. * @param currentRank defines the current fallback rank.
  46915. * @returns the new fallback rank.
  46916. */
  46917. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46918. /**
  46919. * Add the required uniforms to the current list.
  46920. * @param uniforms defines the current uniform list.
  46921. */
  46922. static AddUniforms(uniforms: string[]): void;
  46923. /**
  46924. * Add the required uniforms to the current buffer.
  46925. * @param uniformBuffer defines the current uniform buffer.
  46926. */
  46927. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46928. /**
  46929. * Add the required samplers to the current list.
  46930. * @param samplers defines the current sampler list.
  46931. */
  46932. static AddSamplers(samplers: string[]): void;
  46933. /**
  46934. * Makes a duplicate of the current configuration into another one.
  46935. * @param sheenConfiguration define the config where to copy the info
  46936. */
  46937. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46938. /**
  46939. * Serializes this BRDF configuration.
  46940. * @returns - An object with the serialized config.
  46941. */
  46942. serialize(): any;
  46943. /**
  46944. * Parses a anisotropy Configuration from a serialized object.
  46945. * @param source - Serialized object.
  46946. * @param scene Defines the scene we are parsing for
  46947. * @param rootUrl Defines the rootUrl to load from
  46948. */
  46949. parse(source: any, scene: Scene, rootUrl: string): void;
  46950. }
  46951. }
  46952. declare module BABYLON {
  46953. /**
  46954. * @hidden
  46955. */
  46956. export interface IMaterialSubSurfaceDefines {
  46957. SUBSURFACE: boolean;
  46958. SS_REFRACTION: boolean;
  46959. SS_TRANSLUCENCY: boolean;
  46960. SS_SCATERRING: boolean;
  46961. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46962. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46963. SS_REFRACTIONMAP_3D: boolean;
  46964. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46965. SS_LODINREFRACTIONALPHA: boolean;
  46966. SS_GAMMAREFRACTION: boolean;
  46967. SS_RGBDREFRACTION: boolean;
  46968. SS_LINEARSPECULARREFRACTION: boolean;
  46969. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46970. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46971. /** @hidden */
  46972. _areTexturesDirty: boolean;
  46973. }
  46974. /**
  46975. * Define the code related to the sub surface parameters of the pbr material.
  46976. */
  46977. export class PBRSubSurfaceConfiguration {
  46978. private _isRefractionEnabled;
  46979. /**
  46980. * Defines if the refraction is enabled in the material.
  46981. */
  46982. isRefractionEnabled: boolean;
  46983. private _isTranslucencyEnabled;
  46984. /**
  46985. * Defines if the translucency is enabled in the material.
  46986. */
  46987. isTranslucencyEnabled: boolean;
  46988. private _isScatteringEnabled;
  46989. /**
  46990. * Defines the refraction intensity of the material.
  46991. * The refraction when enabled replaces the Diffuse part of the material.
  46992. * The intensity helps transitionning between diffuse and refraction.
  46993. */
  46994. refractionIntensity: number;
  46995. /**
  46996. * Defines the translucency intensity of the material.
  46997. * When translucency has been enabled, this defines how much of the "translucency"
  46998. * is addded to the diffuse part of the material.
  46999. */
  47000. translucencyIntensity: number;
  47001. /**
  47002. * Defines the scattering intensity of the material.
  47003. * When scattering has been enabled, this defines how much of the "scattered light"
  47004. * is addded to the diffuse part of the material.
  47005. */
  47006. scatteringIntensity: number;
  47007. private _thicknessTexture;
  47008. /**
  47009. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47010. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47011. * 0 would mean minimumThickness
  47012. * 1 would mean maximumThickness
  47013. * The other channels might be use as a mask to vary the different effects intensity.
  47014. */
  47015. thicknessTexture: Nullable<BaseTexture>;
  47016. private _refractionTexture;
  47017. /**
  47018. * Defines the texture to use for refraction.
  47019. */
  47020. refractionTexture: Nullable<BaseTexture>;
  47021. private _indexOfRefraction;
  47022. /**
  47023. * Defines the index of refraction used in the material.
  47024. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47025. */
  47026. indexOfRefraction: number;
  47027. private _invertRefractionY;
  47028. /**
  47029. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47030. */
  47031. invertRefractionY: boolean;
  47032. private _linkRefractionWithTransparency;
  47033. /**
  47034. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47035. * Materials half opaque for instance using refraction could benefit from this control.
  47036. */
  47037. linkRefractionWithTransparency: boolean;
  47038. /**
  47039. * Defines the minimum thickness stored in the thickness map.
  47040. * If no thickness map is defined, this value will be used to simulate thickness.
  47041. */
  47042. minimumThickness: number;
  47043. /**
  47044. * Defines the maximum thickness stored in the thickness map.
  47045. */
  47046. maximumThickness: number;
  47047. /**
  47048. * Defines the volume tint of the material.
  47049. * This is used for both translucency and scattering.
  47050. */
  47051. tintColor: Color3;
  47052. /**
  47053. * Defines the distance at which the tint color should be found in the media.
  47054. * This is used for refraction only.
  47055. */
  47056. tintColorAtDistance: number;
  47057. /**
  47058. * Defines how far each channel transmit through the media.
  47059. * It is defined as a color to simplify it selection.
  47060. */
  47061. diffusionDistance: Color3;
  47062. private _useMaskFromThicknessTexture;
  47063. /**
  47064. * Stores the intensity of the different subsurface effects in the thickness texture.
  47065. * * the green channel is the translucency intensity.
  47066. * * the blue channel is the scattering intensity.
  47067. * * the alpha channel is the refraction intensity.
  47068. */
  47069. useMaskFromThicknessTexture: boolean;
  47070. /** @hidden */
  47071. private _internalMarkAllSubMeshesAsTexturesDirty;
  47072. /** @hidden */
  47073. _markAllSubMeshesAsTexturesDirty(): void;
  47074. /**
  47075. * Instantiate a new istance of sub surface configuration.
  47076. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47077. */
  47078. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47079. /**
  47080. * Gets wehter the submesh is ready to be used or not.
  47081. * @param defines the list of "defines" to update.
  47082. * @param scene defines the scene the material belongs to.
  47083. * @returns - boolean indicating that the submesh is ready or not.
  47084. */
  47085. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47086. /**
  47087. * Checks to see if a texture is used in the material.
  47088. * @param defines the list of "defines" to update.
  47089. * @param scene defines the scene to the material belongs to.
  47090. */
  47091. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47092. /**
  47093. * Binds the material data.
  47094. * @param uniformBuffer defines the Uniform buffer to fill in.
  47095. * @param scene defines the scene the material belongs to.
  47096. * @param engine defines the engine the material belongs to.
  47097. * @param isFrozen defines wether the material is frozen or not.
  47098. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47099. */
  47100. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47101. /**
  47102. * Unbinds the material from the mesh.
  47103. * @param activeEffect defines the effect that should be unbound from.
  47104. * @returns true if unbound, otherwise false
  47105. */
  47106. unbind(activeEffect: Effect): boolean;
  47107. /**
  47108. * Returns the texture used for refraction or null if none is used.
  47109. * @param scene defines the scene the material belongs to.
  47110. * @returns - Refraction texture if present. If no refraction texture and refraction
  47111. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47112. */
  47113. private _getRefractionTexture;
  47114. /**
  47115. * Returns true if alpha blending should be disabled.
  47116. */
  47117. readonly disableAlphaBlending: boolean;
  47118. /**
  47119. * Fills the list of render target textures.
  47120. * @param renderTargets the list of render targets to update
  47121. */
  47122. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47123. /**
  47124. * Checks to see if a texture is used in the material.
  47125. * @param texture - Base texture to use.
  47126. * @returns - Boolean specifying if a texture is used in the material.
  47127. */
  47128. hasTexture(texture: BaseTexture): boolean;
  47129. /**
  47130. * Gets a boolean indicating that current material needs to register RTT
  47131. * @returns true if this uses a render target otherwise false.
  47132. */
  47133. hasRenderTargetTextures(): boolean;
  47134. /**
  47135. * Returns an array of the actively used textures.
  47136. * @param activeTextures Array of BaseTextures
  47137. */
  47138. getActiveTextures(activeTextures: BaseTexture[]): void;
  47139. /**
  47140. * Returns the animatable textures.
  47141. * @param animatables Array of animatable textures.
  47142. */
  47143. getAnimatables(animatables: IAnimatable[]): void;
  47144. /**
  47145. * Disposes the resources of the material.
  47146. * @param forceDisposeTextures - Forces the disposal of all textures.
  47147. */
  47148. dispose(forceDisposeTextures?: boolean): void;
  47149. /**
  47150. * Get the current class name of the texture useful for serialization or dynamic coding.
  47151. * @returns "PBRSubSurfaceConfiguration"
  47152. */
  47153. getClassName(): string;
  47154. /**
  47155. * Add fallbacks to the effect fallbacks list.
  47156. * @param defines defines the Base texture to use.
  47157. * @param fallbacks defines the current fallback list.
  47158. * @param currentRank defines the current fallback rank.
  47159. * @returns the new fallback rank.
  47160. */
  47161. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47162. /**
  47163. * Add the required uniforms to the current list.
  47164. * @param uniforms defines the current uniform list.
  47165. */
  47166. static AddUniforms(uniforms: string[]): void;
  47167. /**
  47168. * Add the required samplers to the current list.
  47169. * @param samplers defines the current sampler list.
  47170. */
  47171. static AddSamplers(samplers: string[]): void;
  47172. /**
  47173. * Add the required uniforms to the current buffer.
  47174. * @param uniformBuffer defines the current uniform buffer.
  47175. */
  47176. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47177. /**
  47178. * Makes a duplicate of the current configuration into another one.
  47179. * @param configuration define the config where to copy the info
  47180. */
  47181. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47182. /**
  47183. * Serializes this Sub Surface configuration.
  47184. * @returns - An object with the serialized config.
  47185. */
  47186. serialize(): any;
  47187. /**
  47188. * Parses a anisotropy Configuration from a serialized object.
  47189. * @param source - Serialized object.
  47190. * @param scene Defines the scene we are parsing for
  47191. * @param rootUrl Defines the rootUrl to load from
  47192. */
  47193. parse(source: any, scene: Scene, rootUrl: string): void;
  47194. }
  47195. }
  47196. declare module BABYLON {
  47197. /** @hidden */
  47198. export var pbrFragmentDeclaration: {
  47199. name: string;
  47200. shader: string;
  47201. };
  47202. }
  47203. declare module BABYLON {
  47204. /** @hidden */
  47205. export var pbrUboDeclaration: {
  47206. name: string;
  47207. shader: string;
  47208. };
  47209. }
  47210. declare module BABYLON {
  47211. /** @hidden */
  47212. export var pbrFragmentExtraDeclaration: {
  47213. name: string;
  47214. shader: string;
  47215. };
  47216. }
  47217. declare module BABYLON {
  47218. /** @hidden */
  47219. export var pbrFragmentSamplersDeclaration: {
  47220. name: string;
  47221. shader: string;
  47222. };
  47223. }
  47224. declare module BABYLON {
  47225. /** @hidden */
  47226. export var pbrHelperFunctions: {
  47227. name: string;
  47228. shader: string;
  47229. };
  47230. }
  47231. declare module BABYLON {
  47232. /** @hidden */
  47233. export var harmonicsFunctions: {
  47234. name: string;
  47235. shader: string;
  47236. };
  47237. }
  47238. declare module BABYLON {
  47239. /** @hidden */
  47240. export var pbrDirectLightingSetupFunctions: {
  47241. name: string;
  47242. shader: string;
  47243. };
  47244. }
  47245. declare module BABYLON {
  47246. /** @hidden */
  47247. export var pbrDirectLightingFalloffFunctions: {
  47248. name: string;
  47249. shader: string;
  47250. };
  47251. }
  47252. declare module BABYLON {
  47253. /** @hidden */
  47254. export var pbrBRDFFunctions: {
  47255. name: string;
  47256. shader: string;
  47257. };
  47258. }
  47259. declare module BABYLON {
  47260. /** @hidden */
  47261. export var pbrDirectLightingFunctions: {
  47262. name: string;
  47263. shader: string;
  47264. };
  47265. }
  47266. declare module BABYLON {
  47267. /** @hidden */
  47268. export var pbrIBLFunctions: {
  47269. name: string;
  47270. shader: string;
  47271. };
  47272. }
  47273. declare module BABYLON {
  47274. /** @hidden */
  47275. export var pbrDebug: {
  47276. name: string;
  47277. shader: string;
  47278. };
  47279. }
  47280. declare module BABYLON {
  47281. /** @hidden */
  47282. export var pbrPixelShader: {
  47283. name: string;
  47284. shader: string;
  47285. };
  47286. }
  47287. declare module BABYLON {
  47288. /** @hidden */
  47289. export var pbrVertexDeclaration: {
  47290. name: string;
  47291. shader: string;
  47292. };
  47293. }
  47294. declare module BABYLON {
  47295. /** @hidden */
  47296. export var pbrVertexShader: {
  47297. name: string;
  47298. shader: string;
  47299. };
  47300. }
  47301. declare module BABYLON {
  47302. /**
  47303. * Manages the defines for the PBR Material.
  47304. * @hidden
  47305. */
  47306. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47307. PBR: boolean;
  47308. MAINUV1: boolean;
  47309. MAINUV2: boolean;
  47310. UV1: boolean;
  47311. UV2: boolean;
  47312. ALBEDO: boolean;
  47313. ALBEDODIRECTUV: number;
  47314. VERTEXCOLOR: boolean;
  47315. AMBIENT: boolean;
  47316. AMBIENTDIRECTUV: number;
  47317. AMBIENTINGRAYSCALE: boolean;
  47318. OPACITY: boolean;
  47319. VERTEXALPHA: boolean;
  47320. OPACITYDIRECTUV: number;
  47321. OPACITYRGB: boolean;
  47322. ALPHATEST: boolean;
  47323. DEPTHPREPASS: boolean;
  47324. ALPHABLEND: boolean;
  47325. ALPHAFROMALBEDO: boolean;
  47326. ALPHATESTVALUE: string;
  47327. SPECULAROVERALPHA: boolean;
  47328. RADIANCEOVERALPHA: boolean;
  47329. ALPHAFRESNEL: boolean;
  47330. LINEARALPHAFRESNEL: boolean;
  47331. PREMULTIPLYALPHA: boolean;
  47332. EMISSIVE: boolean;
  47333. EMISSIVEDIRECTUV: number;
  47334. REFLECTIVITY: boolean;
  47335. REFLECTIVITYDIRECTUV: number;
  47336. SPECULARTERM: boolean;
  47337. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47338. MICROSURFACEAUTOMATIC: boolean;
  47339. LODBASEDMICROSFURACE: boolean;
  47340. MICROSURFACEMAP: boolean;
  47341. MICROSURFACEMAPDIRECTUV: number;
  47342. METALLICWORKFLOW: boolean;
  47343. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47344. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47345. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47346. AOSTOREINMETALMAPRED: boolean;
  47347. ENVIRONMENTBRDF: boolean;
  47348. ENVIRONMENTBRDF_RGBD: boolean;
  47349. NORMAL: boolean;
  47350. TANGENT: boolean;
  47351. BUMP: boolean;
  47352. BUMPDIRECTUV: number;
  47353. OBJECTSPACE_NORMALMAP: boolean;
  47354. PARALLAX: boolean;
  47355. PARALLAXOCCLUSION: boolean;
  47356. NORMALXYSCALE: boolean;
  47357. LIGHTMAP: boolean;
  47358. LIGHTMAPDIRECTUV: number;
  47359. USELIGHTMAPASSHADOWMAP: boolean;
  47360. GAMMALIGHTMAP: boolean;
  47361. RGBDLIGHTMAP: boolean;
  47362. REFLECTION: boolean;
  47363. REFLECTIONMAP_3D: boolean;
  47364. REFLECTIONMAP_SPHERICAL: boolean;
  47365. REFLECTIONMAP_PLANAR: boolean;
  47366. REFLECTIONMAP_CUBIC: boolean;
  47367. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47368. REFLECTIONMAP_PROJECTION: boolean;
  47369. REFLECTIONMAP_SKYBOX: boolean;
  47370. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47371. REFLECTIONMAP_EXPLICIT: boolean;
  47372. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47373. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47374. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47375. INVERTCUBICMAP: boolean;
  47376. USESPHERICALFROMREFLECTIONMAP: boolean;
  47377. USEIRRADIANCEMAP: boolean;
  47378. SPHERICAL_HARMONICS: boolean;
  47379. USESPHERICALINVERTEX: boolean;
  47380. REFLECTIONMAP_OPPOSITEZ: boolean;
  47381. LODINREFLECTIONALPHA: boolean;
  47382. GAMMAREFLECTION: boolean;
  47383. RGBDREFLECTION: boolean;
  47384. LINEARSPECULARREFLECTION: boolean;
  47385. RADIANCEOCCLUSION: boolean;
  47386. HORIZONOCCLUSION: boolean;
  47387. INSTANCES: boolean;
  47388. NUM_BONE_INFLUENCERS: number;
  47389. BonesPerMesh: number;
  47390. BONETEXTURE: boolean;
  47391. NONUNIFORMSCALING: boolean;
  47392. MORPHTARGETS: boolean;
  47393. MORPHTARGETS_NORMAL: boolean;
  47394. MORPHTARGETS_TANGENT: boolean;
  47395. MORPHTARGETS_UV: boolean;
  47396. NUM_MORPH_INFLUENCERS: number;
  47397. IMAGEPROCESSING: boolean;
  47398. VIGNETTE: boolean;
  47399. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47400. VIGNETTEBLENDMODEOPAQUE: boolean;
  47401. TONEMAPPING: boolean;
  47402. TONEMAPPING_ACES: boolean;
  47403. CONTRAST: boolean;
  47404. COLORCURVES: boolean;
  47405. COLORGRADING: boolean;
  47406. COLORGRADING3D: boolean;
  47407. SAMPLER3DGREENDEPTH: boolean;
  47408. SAMPLER3DBGRMAP: boolean;
  47409. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47410. EXPOSURE: boolean;
  47411. MULTIVIEW: boolean;
  47412. USEPHYSICALLIGHTFALLOFF: boolean;
  47413. USEGLTFLIGHTFALLOFF: boolean;
  47414. TWOSIDEDLIGHTING: boolean;
  47415. SHADOWFLOAT: boolean;
  47416. CLIPPLANE: boolean;
  47417. CLIPPLANE2: boolean;
  47418. CLIPPLANE3: boolean;
  47419. CLIPPLANE4: boolean;
  47420. POINTSIZE: boolean;
  47421. FOG: boolean;
  47422. LOGARITHMICDEPTH: boolean;
  47423. FORCENORMALFORWARD: boolean;
  47424. SPECULARAA: boolean;
  47425. CLEARCOAT: boolean;
  47426. CLEARCOAT_DEFAULTIOR: boolean;
  47427. CLEARCOAT_TEXTURE: boolean;
  47428. CLEARCOAT_TEXTUREDIRECTUV: number;
  47429. CLEARCOAT_BUMP: boolean;
  47430. CLEARCOAT_BUMPDIRECTUV: number;
  47431. CLEARCOAT_TINT: boolean;
  47432. CLEARCOAT_TINT_TEXTURE: boolean;
  47433. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47434. ANISOTROPIC: boolean;
  47435. ANISOTROPIC_TEXTURE: boolean;
  47436. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47437. BRDF_V_HEIGHT_CORRELATED: boolean;
  47438. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47439. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  47440. SHEEN: boolean;
  47441. SHEEN_TEXTURE: boolean;
  47442. SHEEN_TEXTUREDIRECTUV: number;
  47443. SHEEN_LINKWITHALBEDO: boolean;
  47444. SUBSURFACE: boolean;
  47445. SS_REFRACTION: boolean;
  47446. SS_TRANSLUCENCY: boolean;
  47447. SS_SCATERRING: boolean;
  47448. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47449. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47450. SS_REFRACTIONMAP_3D: boolean;
  47451. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47452. SS_LODINREFRACTIONALPHA: boolean;
  47453. SS_GAMMAREFRACTION: boolean;
  47454. SS_RGBDREFRACTION: boolean;
  47455. SS_LINEARSPECULARREFRACTION: boolean;
  47456. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47457. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47458. UNLIT: boolean;
  47459. DEBUGMODE: number;
  47460. /**
  47461. * Initializes the PBR Material defines.
  47462. */
  47463. constructor();
  47464. /**
  47465. * Resets the PBR Material defines.
  47466. */
  47467. reset(): void;
  47468. }
  47469. /**
  47470. * The Physically based material base class of BJS.
  47471. *
  47472. * This offers the main features of a standard PBR material.
  47473. * For more information, please refer to the documentation :
  47474. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47475. */
  47476. export abstract class PBRBaseMaterial extends PushMaterial {
  47477. /**
  47478. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47479. */
  47480. static readonly PBRMATERIAL_OPAQUE: number;
  47481. /**
  47482. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47483. */
  47484. static readonly PBRMATERIAL_ALPHATEST: number;
  47485. /**
  47486. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47487. */
  47488. static readonly PBRMATERIAL_ALPHABLEND: number;
  47489. /**
  47490. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47491. * They are also discarded below the alpha cutoff threshold to improve performances.
  47492. */
  47493. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47494. /**
  47495. * Defines the default value of how much AO map is occluding the analytical lights
  47496. * (point spot...).
  47497. */
  47498. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47499. /**
  47500. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47501. */
  47502. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47503. /**
  47504. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47505. * to enhance interoperability with other engines.
  47506. */
  47507. static readonly LIGHTFALLOFF_GLTF: number;
  47508. /**
  47509. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47510. * to enhance interoperability with other materials.
  47511. */
  47512. static readonly LIGHTFALLOFF_STANDARD: number;
  47513. /**
  47514. * Intensity of the direct lights e.g. the four lights available in your scene.
  47515. * This impacts both the direct diffuse and specular highlights.
  47516. */
  47517. protected _directIntensity: number;
  47518. /**
  47519. * Intensity of the emissive part of the material.
  47520. * This helps controlling the emissive effect without modifying the emissive color.
  47521. */
  47522. protected _emissiveIntensity: number;
  47523. /**
  47524. * Intensity of the environment e.g. how much the environment will light the object
  47525. * either through harmonics for rough material or through the refelction for shiny ones.
  47526. */
  47527. protected _environmentIntensity: number;
  47528. /**
  47529. * This is a special control allowing the reduction of the specular highlights coming from the
  47530. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47531. */
  47532. protected _specularIntensity: number;
  47533. /**
  47534. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47535. */
  47536. private _lightingInfos;
  47537. /**
  47538. * Debug Control allowing disabling the bump map on this material.
  47539. */
  47540. protected _disableBumpMap: boolean;
  47541. /**
  47542. * AKA Diffuse Texture in standard nomenclature.
  47543. */
  47544. protected _albedoTexture: Nullable<BaseTexture>;
  47545. /**
  47546. * AKA Occlusion Texture in other nomenclature.
  47547. */
  47548. protected _ambientTexture: Nullable<BaseTexture>;
  47549. /**
  47550. * AKA Occlusion Texture Intensity in other nomenclature.
  47551. */
  47552. protected _ambientTextureStrength: number;
  47553. /**
  47554. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47555. * 1 means it completely occludes it
  47556. * 0 mean it has no impact
  47557. */
  47558. protected _ambientTextureImpactOnAnalyticalLights: number;
  47559. /**
  47560. * Stores the alpha values in a texture.
  47561. */
  47562. protected _opacityTexture: Nullable<BaseTexture>;
  47563. /**
  47564. * Stores the reflection values in a texture.
  47565. */
  47566. protected _reflectionTexture: Nullable<BaseTexture>;
  47567. /**
  47568. * Stores the emissive values in a texture.
  47569. */
  47570. protected _emissiveTexture: Nullable<BaseTexture>;
  47571. /**
  47572. * AKA Specular texture in other nomenclature.
  47573. */
  47574. protected _reflectivityTexture: Nullable<BaseTexture>;
  47575. /**
  47576. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47577. */
  47578. protected _metallicTexture: Nullable<BaseTexture>;
  47579. /**
  47580. * Specifies the metallic scalar of the metallic/roughness workflow.
  47581. * Can also be used to scale the metalness values of the metallic texture.
  47582. */
  47583. protected _metallic: Nullable<number>;
  47584. /**
  47585. * Specifies the roughness scalar of the metallic/roughness workflow.
  47586. * Can also be used to scale the roughness values of the metallic texture.
  47587. */
  47588. protected _roughness: Nullable<number>;
  47589. /**
  47590. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47591. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47592. */
  47593. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47594. /**
  47595. * Stores surface normal data used to displace a mesh in a texture.
  47596. */
  47597. protected _bumpTexture: Nullable<BaseTexture>;
  47598. /**
  47599. * Stores the pre-calculated light information of a mesh in a texture.
  47600. */
  47601. protected _lightmapTexture: Nullable<BaseTexture>;
  47602. /**
  47603. * The color of a material in ambient lighting.
  47604. */
  47605. protected _ambientColor: Color3;
  47606. /**
  47607. * AKA Diffuse Color in other nomenclature.
  47608. */
  47609. protected _albedoColor: Color3;
  47610. /**
  47611. * AKA Specular Color in other nomenclature.
  47612. */
  47613. protected _reflectivityColor: Color3;
  47614. /**
  47615. * The color applied when light is reflected from a material.
  47616. */
  47617. protected _reflectionColor: Color3;
  47618. /**
  47619. * The color applied when light is emitted from a material.
  47620. */
  47621. protected _emissiveColor: Color3;
  47622. /**
  47623. * AKA Glossiness in other nomenclature.
  47624. */
  47625. protected _microSurface: number;
  47626. /**
  47627. * Specifies that the material will use the light map as a show map.
  47628. */
  47629. protected _useLightmapAsShadowmap: boolean;
  47630. /**
  47631. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47632. * makes the reflect vector face the model (under horizon).
  47633. */
  47634. protected _useHorizonOcclusion: boolean;
  47635. /**
  47636. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47637. * too much the area relying on ambient texture to define their ambient occlusion.
  47638. */
  47639. protected _useRadianceOcclusion: boolean;
  47640. /**
  47641. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47642. */
  47643. protected _useAlphaFromAlbedoTexture: boolean;
  47644. /**
  47645. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47646. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47647. */
  47648. protected _useSpecularOverAlpha: boolean;
  47649. /**
  47650. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47651. */
  47652. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47653. /**
  47654. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47655. */
  47656. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47657. /**
  47658. * Specifies if the metallic texture contains the roughness information in its green channel.
  47659. */
  47660. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47661. /**
  47662. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47663. */
  47664. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47665. /**
  47666. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47667. */
  47668. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47669. /**
  47670. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47671. */
  47672. protected _useAmbientInGrayScale: boolean;
  47673. /**
  47674. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47675. * The material will try to infer what glossiness each pixel should be.
  47676. */
  47677. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47678. /**
  47679. * Defines the falloff type used in this material.
  47680. * It by default is Physical.
  47681. */
  47682. protected _lightFalloff: number;
  47683. /**
  47684. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47685. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47686. */
  47687. protected _useRadianceOverAlpha: boolean;
  47688. /**
  47689. * Allows using an object space normal map (instead of tangent space).
  47690. */
  47691. protected _useObjectSpaceNormalMap: boolean;
  47692. /**
  47693. * Allows using the bump map in parallax mode.
  47694. */
  47695. protected _useParallax: boolean;
  47696. /**
  47697. * Allows using the bump map in parallax occlusion mode.
  47698. */
  47699. protected _useParallaxOcclusion: boolean;
  47700. /**
  47701. * Controls the scale bias of the parallax mode.
  47702. */
  47703. protected _parallaxScaleBias: number;
  47704. /**
  47705. * If sets to true, disables all the lights affecting the material.
  47706. */
  47707. protected _disableLighting: boolean;
  47708. /**
  47709. * Number of Simultaneous lights allowed on the material.
  47710. */
  47711. protected _maxSimultaneousLights: number;
  47712. /**
  47713. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47714. */
  47715. protected _invertNormalMapX: boolean;
  47716. /**
  47717. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47718. */
  47719. protected _invertNormalMapY: boolean;
  47720. /**
  47721. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47722. */
  47723. protected _twoSidedLighting: boolean;
  47724. /**
  47725. * Defines the alpha limits in alpha test mode.
  47726. */
  47727. protected _alphaCutOff: number;
  47728. /**
  47729. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47730. */
  47731. protected _forceAlphaTest: boolean;
  47732. /**
  47733. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47734. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47735. */
  47736. protected _useAlphaFresnel: boolean;
  47737. /**
  47738. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47739. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47740. */
  47741. protected _useLinearAlphaFresnel: boolean;
  47742. /**
  47743. * The transparency mode of the material.
  47744. */
  47745. protected _transparencyMode: Nullable<number>;
  47746. /**
  47747. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47748. * from cos thetav and roughness:
  47749. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47750. */
  47751. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47752. /**
  47753. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47754. */
  47755. protected _forceIrradianceInFragment: boolean;
  47756. /**
  47757. * Force normal to face away from face.
  47758. */
  47759. protected _forceNormalForward: boolean;
  47760. /**
  47761. * Enables specular anti aliasing in the PBR shader.
  47762. * It will both interacts on the Geometry for analytical and IBL lighting.
  47763. * It also prefilter the roughness map based on the bump values.
  47764. */
  47765. protected _enableSpecularAntiAliasing: boolean;
  47766. /**
  47767. * Default configuration related to image processing available in the PBR Material.
  47768. */
  47769. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47770. /**
  47771. * Keep track of the image processing observer to allow dispose and replace.
  47772. */
  47773. private _imageProcessingObserver;
  47774. /**
  47775. * Attaches a new image processing configuration to the PBR Material.
  47776. * @param configuration
  47777. */
  47778. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47779. /**
  47780. * Stores the available render targets.
  47781. */
  47782. private _renderTargets;
  47783. /**
  47784. * Sets the global ambient color for the material used in lighting calculations.
  47785. */
  47786. private _globalAmbientColor;
  47787. /**
  47788. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47789. */
  47790. private _useLogarithmicDepth;
  47791. /**
  47792. * If set to true, no lighting calculations will be applied.
  47793. */
  47794. private _unlit;
  47795. private _debugMode;
  47796. /**
  47797. * @hidden
  47798. * This is reserved for the inspector.
  47799. * Defines the material debug mode.
  47800. * It helps seeing only some components of the material while troubleshooting.
  47801. */
  47802. debugMode: number;
  47803. /**
  47804. * @hidden
  47805. * This is reserved for the inspector.
  47806. * Specify from where on screen the debug mode should start.
  47807. * The value goes from -1 (full screen) to 1 (not visible)
  47808. * It helps with side by side comparison against the final render
  47809. * This defaults to -1
  47810. */
  47811. private debugLimit;
  47812. /**
  47813. * @hidden
  47814. * This is reserved for the inspector.
  47815. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47816. * You can use the factor to better multiply the final value.
  47817. */
  47818. private debugFactor;
  47819. /**
  47820. * Defines the clear coat layer parameters for the material.
  47821. */
  47822. readonly clearCoat: PBRClearCoatConfiguration;
  47823. /**
  47824. * Defines the anisotropic parameters for the material.
  47825. */
  47826. readonly anisotropy: PBRAnisotropicConfiguration;
  47827. /**
  47828. * Defines the BRDF parameters for the material.
  47829. */
  47830. readonly brdf: PBRBRDFConfiguration;
  47831. /**
  47832. * Defines the Sheen parameters for the material.
  47833. */
  47834. readonly sheen: PBRSheenConfiguration;
  47835. /**
  47836. * Defines the SubSurface parameters for the material.
  47837. */
  47838. readonly subSurface: PBRSubSurfaceConfiguration;
  47839. /**
  47840. * Custom callback helping to override the default shader used in the material.
  47841. */
  47842. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47843. protected _rebuildInParallel: boolean;
  47844. /**
  47845. * Instantiates a new PBRMaterial instance.
  47846. *
  47847. * @param name The material name
  47848. * @param scene The scene the material will be use in.
  47849. */
  47850. constructor(name: string, scene: Scene);
  47851. /**
  47852. * Gets a boolean indicating that current material needs to register RTT
  47853. */
  47854. readonly hasRenderTargetTextures: boolean;
  47855. /**
  47856. * Gets the name of the material class.
  47857. */
  47858. getClassName(): string;
  47859. /**
  47860. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47861. */
  47862. /**
  47863. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47864. */
  47865. useLogarithmicDepth: boolean;
  47866. /**
  47867. * Gets the current transparency mode.
  47868. */
  47869. /**
  47870. * Sets the transparency mode of the material.
  47871. *
  47872. * | Value | Type | Description |
  47873. * | ----- | ----------------------------------- | ----------- |
  47874. * | 0 | OPAQUE | |
  47875. * | 1 | ALPHATEST | |
  47876. * | 2 | ALPHABLEND | |
  47877. * | 3 | ALPHATESTANDBLEND | |
  47878. *
  47879. */
  47880. transparencyMode: Nullable<number>;
  47881. /**
  47882. * Returns true if alpha blending should be disabled.
  47883. */
  47884. private readonly _disableAlphaBlending;
  47885. /**
  47886. * Specifies whether or not this material should be rendered in alpha blend mode.
  47887. */
  47888. needAlphaBlending(): boolean;
  47889. /**
  47890. * Specifies if the mesh will require alpha blending.
  47891. * @param mesh - BJS mesh.
  47892. */
  47893. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47894. /**
  47895. * Specifies whether or not this material should be rendered in alpha test mode.
  47896. */
  47897. needAlphaTesting(): boolean;
  47898. /**
  47899. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47900. */
  47901. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47902. /**
  47903. * Gets the texture used for the alpha test.
  47904. */
  47905. getAlphaTestTexture(): Nullable<BaseTexture>;
  47906. /**
  47907. * Specifies that the submesh is ready to be used.
  47908. * @param mesh - BJS mesh.
  47909. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47910. * @param useInstances - Specifies that instances should be used.
  47911. * @returns - boolean indicating that the submesh is ready or not.
  47912. */
  47913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47914. /**
  47915. * Specifies if the material uses metallic roughness workflow.
  47916. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47917. */
  47918. isMetallicWorkflow(): boolean;
  47919. private _prepareEffect;
  47920. private _prepareDefines;
  47921. /**
  47922. * Force shader compilation
  47923. */
  47924. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47925. clipPlane: boolean;
  47926. }>): void;
  47927. /**
  47928. * Initializes the uniform buffer layout for the shader.
  47929. */
  47930. buildUniformLayout(): void;
  47931. /**
  47932. * Unbinds the material from the mesh
  47933. */
  47934. unbind(): void;
  47935. /**
  47936. * Binds the submesh data.
  47937. * @param world - The world matrix.
  47938. * @param mesh - The BJS mesh.
  47939. * @param subMesh - A submesh of the BJS mesh.
  47940. */
  47941. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47942. /**
  47943. * Returns the animatable textures.
  47944. * @returns - Array of animatable textures.
  47945. */
  47946. getAnimatables(): IAnimatable[];
  47947. /**
  47948. * Returns the texture used for reflections.
  47949. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47950. */
  47951. private _getReflectionTexture;
  47952. /**
  47953. * Returns an array of the actively used textures.
  47954. * @returns - Array of BaseTextures
  47955. */
  47956. getActiveTextures(): BaseTexture[];
  47957. /**
  47958. * Checks to see if a texture is used in the material.
  47959. * @param texture - Base texture to use.
  47960. * @returns - Boolean specifying if a texture is used in the material.
  47961. */
  47962. hasTexture(texture: BaseTexture): boolean;
  47963. /**
  47964. * Disposes the resources of the material.
  47965. * @param forceDisposeEffect - Forces the disposal of effects.
  47966. * @param forceDisposeTextures - Forces the disposal of all textures.
  47967. */
  47968. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47969. }
  47970. }
  47971. declare module BABYLON {
  47972. /**
  47973. * The Physically based material of BJS.
  47974. *
  47975. * This offers the main features of a standard PBR material.
  47976. * For more information, please refer to the documentation :
  47977. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47978. */
  47979. export class PBRMaterial extends PBRBaseMaterial {
  47980. /**
  47981. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47982. */
  47983. static readonly PBRMATERIAL_OPAQUE: number;
  47984. /**
  47985. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47986. */
  47987. static readonly PBRMATERIAL_ALPHATEST: number;
  47988. /**
  47989. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47990. */
  47991. static readonly PBRMATERIAL_ALPHABLEND: number;
  47992. /**
  47993. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47994. * They are also discarded below the alpha cutoff threshold to improve performances.
  47995. */
  47996. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47997. /**
  47998. * Defines the default value of how much AO map is occluding the analytical lights
  47999. * (point spot...).
  48000. */
  48001. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48002. /**
  48003. * Intensity of the direct lights e.g. the four lights available in your scene.
  48004. * This impacts both the direct diffuse and specular highlights.
  48005. */
  48006. directIntensity: number;
  48007. /**
  48008. * Intensity of the emissive part of the material.
  48009. * This helps controlling the emissive effect without modifying the emissive color.
  48010. */
  48011. emissiveIntensity: number;
  48012. /**
  48013. * Intensity of the environment e.g. how much the environment will light the object
  48014. * either through harmonics for rough material or through the refelction for shiny ones.
  48015. */
  48016. environmentIntensity: number;
  48017. /**
  48018. * This is a special control allowing the reduction of the specular highlights coming from the
  48019. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48020. */
  48021. specularIntensity: number;
  48022. /**
  48023. * Debug Control allowing disabling the bump map on this material.
  48024. */
  48025. disableBumpMap: boolean;
  48026. /**
  48027. * AKA Diffuse Texture in standard nomenclature.
  48028. */
  48029. albedoTexture: BaseTexture;
  48030. /**
  48031. * AKA Occlusion Texture in other nomenclature.
  48032. */
  48033. ambientTexture: BaseTexture;
  48034. /**
  48035. * AKA Occlusion Texture Intensity in other nomenclature.
  48036. */
  48037. ambientTextureStrength: number;
  48038. /**
  48039. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48040. * 1 means it completely occludes it
  48041. * 0 mean it has no impact
  48042. */
  48043. ambientTextureImpactOnAnalyticalLights: number;
  48044. /**
  48045. * Stores the alpha values in a texture.
  48046. */
  48047. opacityTexture: BaseTexture;
  48048. /**
  48049. * Stores the reflection values in a texture.
  48050. */
  48051. reflectionTexture: Nullable<BaseTexture>;
  48052. /**
  48053. * Stores the emissive values in a texture.
  48054. */
  48055. emissiveTexture: BaseTexture;
  48056. /**
  48057. * AKA Specular texture in other nomenclature.
  48058. */
  48059. reflectivityTexture: BaseTexture;
  48060. /**
  48061. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48062. */
  48063. metallicTexture: BaseTexture;
  48064. /**
  48065. * Specifies the metallic scalar of the metallic/roughness workflow.
  48066. * Can also be used to scale the metalness values of the metallic texture.
  48067. */
  48068. metallic: Nullable<number>;
  48069. /**
  48070. * Specifies the roughness scalar of the metallic/roughness workflow.
  48071. * Can also be used to scale the roughness values of the metallic texture.
  48072. */
  48073. roughness: Nullable<number>;
  48074. /**
  48075. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48076. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48077. */
  48078. microSurfaceTexture: BaseTexture;
  48079. /**
  48080. * Stores surface normal data used to displace a mesh in a texture.
  48081. */
  48082. bumpTexture: BaseTexture;
  48083. /**
  48084. * Stores the pre-calculated light information of a mesh in a texture.
  48085. */
  48086. lightmapTexture: BaseTexture;
  48087. /**
  48088. * Stores the refracted light information in a texture.
  48089. */
  48090. refractionTexture: Nullable<BaseTexture>;
  48091. /**
  48092. * The color of a material in ambient lighting.
  48093. */
  48094. ambientColor: Color3;
  48095. /**
  48096. * AKA Diffuse Color in other nomenclature.
  48097. */
  48098. albedoColor: Color3;
  48099. /**
  48100. * AKA Specular Color in other nomenclature.
  48101. */
  48102. reflectivityColor: Color3;
  48103. /**
  48104. * The color reflected from the material.
  48105. */
  48106. reflectionColor: Color3;
  48107. /**
  48108. * The color emitted from the material.
  48109. */
  48110. emissiveColor: Color3;
  48111. /**
  48112. * AKA Glossiness in other nomenclature.
  48113. */
  48114. microSurface: number;
  48115. /**
  48116. * source material index of refraction (IOR)' / 'destination material IOR.
  48117. */
  48118. indexOfRefraction: number;
  48119. /**
  48120. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48121. */
  48122. invertRefractionY: boolean;
  48123. /**
  48124. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48125. * Materials half opaque for instance using refraction could benefit from this control.
  48126. */
  48127. linkRefractionWithTransparency: boolean;
  48128. /**
  48129. * If true, the light map contains occlusion information instead of lighting info.
  48130. */
  48131. useLightmapAsShadowmap: boolean;
  48132. /**
  48133. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48134. */
  48135. useAlphaFromAlbedoTexture: boolean;
  48136. /**
  48137. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48138. */
  48139. forceAlphaTest: boolean;
  48140. /**
  48141. * Defines the alpha limits in alpha test mode.
  48142. */
  48143. alphaCutOff: number;
  48144. /**
  48145. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48146. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48147. */
  48148. useSpecularOverAlpha: boolean;
  48149. /**
  48150. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48151. */
  48152. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48153. /**
  48154. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48155. */
  48156. useRoughnessFromMetallicTextureAlpha: boolean;
  48157. /**
  48158. * Specifies if the metallic texture contains the roughness information in its green channel.
  48159. */
  48160. useRoughnessFromMetallicTextureGreen: boolean;
  48161. /**
  48162. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48163. */
  48164. useMetallnessFromMetallicTextureBlue: boolean;
  48165. /**
  48166. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48167. */
  48168. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48169. /**
  48170. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48171. */
  48172. useAmbientInGrayScale: boolean;
  48173. /**
  48174. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48175. * The material will try to infer what glossiness each pixel should be.
  48176. */
  48177. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48178. /**
  48179. * BJS is using an harcoded light falloff based on a manually sets up range.
  48180. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48181. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48182. */
  48183. /**
  48184. * BJS is using an harcoded light falloff based on a manually sets up range.
  48185. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48186. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48187. */
  48188. usePhysicalLightFalloff: boolean;
  48189. /**
  48190. * In order to support the falloff compatibility with gltf, a special mode has been added
  48191. * to reproduce the gltf light falloff.
  48192. */
  48193. /**
  48194. * In order to support the falloff compatibility with gltf, a special mode has been added
  48195. * to reproduce the gltf light falloff.
  48196. */
  48197. useGLTFLightFalloff: boolean;
  48198. /**
  48199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48201. */
  48202. useRadianceOverAlpha: boolean;
  48203. /**
  48204. * Allows using an object space normal map (instead of tangent space).
  48205. */
  48206. useObjectSpaceNormalMap: boolean;
  48207. /**
  48208. * Allows using the bump map in parallax mode.
  48209. */
  48210. useParallax: boolean;
  48211. /**
  48212. * Allows using the bump map in parallax occlusion mode.
  48213. */
  48214. useParallaxOcclusion: boolean;
  48215. /**
  48216. * Controls the scale bias of the parallax mode.
  48217. */
  48218. parallaxScaleBias: number;
  48219. /**
  48220. * If sets to true, disables all the lights affecting the material.
  48221. */
  48222. disableLighting: boolean;
  48223. /**
  48224. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48225. */
  48226. forceIrradianceInFragment: boolean;
  48227. /**
  48228. * Number of Simultaneous lights allowed on the material.
  48229. */
  48230. maxSimultaneousLights: number;
  48231. /**
  48232. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48233. */
  48234. invertNormalMapX: boolean;
  48235. /**
  48236. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48237. */
  48238. invertNormalMapY: boolean;
  48239. /**
  48240. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48241. */
  48242. twoSidedLighting: boolean;
  48243. /**
  48244. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48245. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48246. */
  48247. useAlphaFresnel: boolean;
  48248. /**
  48249. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48250. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48251. */
  48252. useLinearAlphaFresnel: boolean;
  48253. /**
  48254. * Let user defines the brdf lookup texture used for IBL.
  48255. * A default 8bit version is embedded but you could point at :
  48256. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48257. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48258. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48259. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48260. */
  48261. environmentBRDFTexture: Nullable<BaseTexture>;
  48262. /**
  48263. * Force normal to face away from face.
  48264. */
  48265. forceNormalForward: boolean;
  48266. /**
  48267. * Enables specular anti aliasing in the PBR shader.
  48268. * It will both interacts on the Geometry for analytical and IBL lighting.
  48269. * It also prefilter the roughness map based on the bump values.
  48270. */
  48271. enableSpecularAntiAliasing: boolean;
  48272. /**
  48273. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48274. * makes the reflect vector face the model (under horizon).
  48275. */
  48276. useHorizonOcclusion: boolean;
  48277. /**
  48278. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48279. * too much the area relying on ambient texture to define their ambient occlusion.
  48280. */
  48281. useRadianceOcclusion: boolean;
  48282. /**
  48283. * If set to true, no lighting calculations will be applied.
  48284. */
  48285. unlit: boolean;
  48286. /**
  48287. * Gets the image processing configuration used either in this material.
  48288. */
  48289. /**
  48290. * Sets the Default image processing configuration used either in the this material.
  48291. *
  48292. * If sets to null, the scene one is in use.
  48293. */
  48294. imageProcessingConfiguration: ImageProcessingConfiguration;
  48295. /**
  48296. * Gets wether the color curves effect is enabled.
  48297. */
  48298. /**
  48299. * Sets wether the color curves effect is enabled.
  48300. */
  48301. cameraColorCurvesEnabled: boolean;
  48302. /**
  48303. * Gets wether the color grading effect is enabled.
  48304. */
  48305. /**
  48306. * Gets wether the color grading effect is enabled.
  48307. */
  48308. cameraColorGradingEnabled: boolean;
  48309. /**
  48310. * Gets wether tonemapping is enabled or not.
  48311. */
  48312. /**
  48313. * Sets wether tonemapping is enabled or not
  48314. */
  48315. cameraToneMappingEnabled: boolean;
  48316. /**
  48317. * The camera exposure used on this material.
  48318. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48319. * This corresponds to a photographic exposure.
  48320. */
  48321. /**
  48322. * The camera exposure used on this material.
  48323. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48324. * This corresponds to a photographic exposure.
  48325. */
  48326. cameraExposure: number;
  48327. /**
  48328. * Gets The camera contrast used on this material.
  48329. */
  48330. /**
  48331. * Sets The camera contrast used on this material.
  48332. */
  48333. cameraContrast: number;
  48334. /**
  48335. * Gets the Color Grading 2D Lookup Texture.
  48336. */
  48337. /**
  48338. * Sets the Color Grading 2D Lookup Texture.
  48339. */
  48340. cameraColorGradingTexture: Nullable<BaseTexture>;
  48341. /**
  48342. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48343. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48344. * 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;
  48345. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48346. */
  48347. /**
  48348. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48349. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48350. * 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;
  48351. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48352. */
  48353. cameraColorCurves: Nullable<ColorCurves>;
  48354. /**
  48355. * Instantiates a new PBRMaterial instance.
  48356. *
  48357. * @param name The material name
  48358. * @param scene The scene the material will be use in.
  48359. */
  48360. constructor(name: string, scene: Scene);
  48361. /**
  48362. * Returns the name of this material class.
  48363. */
  48364. getClassName(): string;
  48365. /**
  48366. * Makes a duplicate of the current material.
  48367. * @param name - name to use for the new material.
  48368. */
  48369. clone(name: string): PBRMaterial;
  48370. /**
  48371. * Serializes this PBR Material.
  48372. * @returns - An object with the serialized material.
  48373. */
  48374. serialize(): any;
  48375. /**
  48376. * Parses a PBR Material from a serialized object.
  48377. * @param source - Serialized object.
  48378. * @param scene - BJS scene instance.
  48379. * @param rootUrl - url for the scene object
  48380. * @returns - PBRMaterial
  48381. */
  48382. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48383. }
  48384. }
  48385. declare module BABYLON {
  48386. /**
  48387. * Direct draw surface info
  48388. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48389. */
  48390. export interface DDSInfo {
  48391. /**
  48392. * Width of the texture
  48393. */
  48394. width: number;
  48395. /**
  48396. * Width of the texture
  48397. */
  48398. height: number;
  48399. /**
  48400. * Number of Mipmaps for the texture
  48401. * @see https://en.wikipedia.org/wiki/Mipmap
  48402. */
  48403. mipmapCount: number;
  48404. /**
  48405. * If the textures format is a known fourCC format
  48406. * @see https://www.fourcc.org/
  48407. */
  48408. isFourCC: boolean;
  48409. /**
  48410. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48411. */
  48412. isRGB: boolean;
  48413. /**
  48414. * If the texture is a lumincance format
  48415. */
  48416. isLuminance: boolean;
  48417. /**
  48418. * If this is a cube texture
  48419. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48420. */
  48421. isCube: boolean;
  48422. /**
  48423. * If the texture is a compressed format eg. FOURCC_DXT1
  48424. */
  48425. isCompressed: boolean;
  48426. /**
  48427. * The dxgiFormat of the texture
  48428. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48429. */
  48430. dxgiFormat: number;
  48431. /**
  48432. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48433. */
  48434. textureType: number;
  48435. /**
  48436. * Sphericle polynomial created for the dds texture
  48437. */
  48438. sphericalPolynomial?: SphericalPolynomial;
  48439. }
  48440. /**
  48441. * Class used to provide DDS decompression tools
  48442. */
  48443. export class DDSTools {
  48444. /**
  48445. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48446. */
  48447. static StoreLODInAlphaChannel: boolean;
  48448. /**
  48449. * Gets DDS information from an array buffer
  48450. * @param arrayBuffer defines the array buffer to read data from
  48451. * @returns the DDS information
  48452. */
  48453. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48454. private static _FloatView;
  48455. private static _Int32View;
  48456. private static _ToHalfFloat;
  48457. private static _FromHalfFloat;
  48458. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48459. private static _GetHalfFloatRGBAArrayBuffer;
  48460. private static _GetFloatRGBAArrayBuffer;
  48461. private static _GetFloatAsUIntRGBAArrayBuffer;
  48462. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48463. private static _GetRGBAArrayBuffer;
  48464. private static _ExtractLongWordOrder;
  48465. private static _GetRGBArrayBuffer;
  48466. private static _GetLuminanceArrayBuffer;
  48467. /**
  48468. * Uploads DDS Levels to a Babylon Texture
  48469. * @hidden
  48470. */
  48471. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48472. }
  48473. interface ThinEngine {
  48474. /**
  48475. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48476. * @param rootUrl defines the url where the file to load is located
  48477. * @param scene defines the current scene
  48478. * @param lodScale defines scale to apply to the mip map selection
  48479. * @param lodOffset defines offset to apply to the mip map selection
  48480. * @param onLoad defines an optional callback raised when the texture is loaded
  48481. * @param onError defines an optional callback raised if there is an issue to load the texture
  48482. * @param format defines the format of the data
  48483. * @param forcedExtension defines the extension to use to pick the right loader
  48484. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48485. * @returns the cube texture as an InternalTexture
  48486. */
  48487. 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;
  48488. }
  48489. }
  48490. declare module BABYLON {
  48491. /**
  48492. * Implementation of the DDS Texture Loader.
  48493. * @hidden
  48494. */
  48495. export class _DDSTextureLoader implements IInternalTextureLoader {
  48496. /**
  48497. * Defines wether the loader supports cascade loading the different faces.
  48498. */
  48499. readonly supportCascades: boolean;
  48500. /**
  48501. * This returns if the loader support the current file information.
  48502. * @param extension defines the file extension of the file being loaded
  48503. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48504. * @param fallback defines the fallback internal texture if any
  48505. * @param isBase64 defines whether the texture is encoded as a base64
  48506. * @param isBuffer defines whether the texture data are stored as a buffer
  48507. * @returns true if the loader can load the specified file
  48508. */
  48509. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48510. /**
  48511. * Transform the url before loading if required.
  48512. * @param rootUrl the url of the texture
  48513. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48514. * @returns the transformed texture
  48515. */
  48516. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48517. /**
  48518. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48519. * @param rootUrl the url of the texture
  48520. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48521. * @returns the fallback texture
  48522. */
  48523. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48524. /**
  48525. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48526. * @param data contains the texture data
  48527. * @param texture defines the BabylonJS internal texture
  48528. * @param createPolynomials will be true if polynomials have been requested
  48529. * @param onLoad defines the callback to trigger once the texture is ready
  48530. * @param onError defines the callback to trigger in case of error
  48531. */
  48532. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48533. /**
  48534. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48535. * @param data contains the texture data
  48536. * @param texture defines the BabylonJS internal texture
  48537. * @param callback defines the method to call once ready to upload
  48538. */
  48539. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48540. }
  48541. }
  48542. declare module BABYLON {
  48543. /**
  48544. * Implementation of the ENV Texture Loader.
  48545. * @hidden
  48546. */
  48547. export class _ENVTextureLoader implements IInternalTextureLoader {
  48548. /**
  48549. * Defines wether the loader supports cascade loading the different faces.
  48550. */
  48551. readonly supportCascades: boolean;
  48552. /**
  48553. * This returns if the loader support the current file information.
  48554. * @param extension defines the file extension of the file being loaded
  48555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48556. * @param fallback defines the fallback internal texture if any
  48557. * @param isBase64 defines whether the texture is encoded as a base64
  48558. * @param isBuffer defines whether the texture data are stored as a buffer
  48559. * @returns true if the loader can load the specified file
  48560. */
  48561. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48562. /**
  48563. * Transform the url before loading if required.
  48564. * @param rootUrl the url of the texture
  48565. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48566. * @returns the transformed texture
  48567. */
  48568. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48569. /**
  48570. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48571. * @param rootUrl the url of the texture
  48572. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48573. * @returns the fallback texture
  48574. */
  48575. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48576. /**
  48577. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48578. * @param data contains the texture data
  48579. * @param texture defines the BabylonJS internal texture
  48580. * @param createPolynomials will be true if polynomials have been requested
  48581. * @param onLoad defines the callback to trigger once the texture is ready
  48582. * @param onError defines the callback to trigger in case of error
  48583. */
  48584. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48585. /**
  48586. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48587. * @param data contains the texture data
  48588. * @param texture defines the BabylonJS internal texture
  48589. * @param callback defines the method to call once ready to upload
  48590. */
  48591. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48592. }
  48593. }
  48594. declare module BABYLON {
  48595. /**
  48596. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48597. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48598. */
  48599. export class KhronosTextureContainer {
  48600. /** contents of the KTX container file */
  48601. arrayBuffer: any;
  48602. private static HEADER_LEN;
  48603. private static COMPRESSED_2D;
  48604. private static COMPRESSED_3D;
  48605. private static TEX_2D;
  48606. private static TEX_3D;
  48607. /**
  48608. * Gets the openGL type
  48609. */
  48610. glType: number;
  48611. /**
  48612. * Gets the openGL type size
  48613. */
  48614. glTypeSize: number;
  48615. /**
  48616. * Gets the openGL format
  48617. */
  48618. glFormat: number;
  48619. /**
  48620. * Gets the openGL internal format
  48621. */
  48622. glInternalFormat: number;
  48623. /**
  48624. * Gets the base internal format
  48625. */
  48626. glBaseInternalFormat: number;
  48627. /**
  48628. * Gets image width in pixel
  48629. */
  48630. pixelWidth: number;
  48631. /**
  48632. * Gets image height in pixel
  48633. */
  48634. pixelHeight: number;
  48635. /**
  48636. * Gets image depth in pixels
  48637. */
  48638. pixelDepth: number;
  48639. /**
  48640. * Gets the number of array elements
  48641. */
  48642. numberOfArrayElements: number;
  48643. /**
  48644. * Gets the number of faces
  48645. */
  48646. numberOfFaces: number;
  48647. /**
  48648. * Gets the number of mipmap levels
  48649. */
  48650. numberOfMipmapLevels: number;
  48651. /**
  48652. * Gets the bytes of key value data
  48653. */
  48654. bytesOfKeyValueData: number;
  48655. /**
  48656. * Gets the load type
  48657. */
  48658. loadType: number;
  48659. /**
  48660. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48661. */
  48662. isInvalid: boolean;
  48663. /**
  48664. * Creates a new KhronosTextureContainer
  48665. * @param arrayBuffer contents of the KTX container file
  48666. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48667. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48668. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48669. */
  48670. constructor(
  48671. /** contents of the KTX container file */
  48672. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48673. /**
  48674. * Uploads KTX content to a Babylon Texture.
  48675. * It is assumed that the texture has already been created & is currently bound
  48676. * @hidden
  48677. */
  48678. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48679. private _upload2DCompressedLevels;
  48680. }
  48681. }
  48682. declare module BABYLON {
  48683. /**
  48684. * Implementation of the KTX Texture Loader.
  48685. * @hidden
  48686. */
  48687. export class _KTXTextureLoader implements IInternalTextureLoader {
  48688. /**
  48689. * Defines wether the loader supports cascade loading the different faces.
  48690. */
  48691. readonly supportCascades: boolean;
  48692. /**
  48693. * This returns if the loader support the current file information.
  48694. * @param extension defines the file extension of the file being loaded
  48695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48696. * @param fallback defines the fallback internal texture if any
  48697. * @param isBase64 defines whether the texture is encoded as a base64
  48698. * @param isBuffer defines whether the texture data are stored as a buffer
  48699. * @returns true if the loader can load the specified file
  48700. */
  48701. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48702. /**
  48703. * Transform the url before loading if required.
  48704. * @param rootUrl the url of the texture
  48705. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48706. * @returns the transformed texture
  48707. */
  48708. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48709. /**
  48710. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48711. * @param rootUrl the url of the texture
  48712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48713. * @returns the fallback texture
  48714. */
  48715. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48716. /**
  48717. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48718. * @param data contains the texture data
  48719. * @param texture defines the BabylonJS internal texture
  48720. * @param createPolynomials will be true if polynomials have been requested
  48721. * @param onLoad defines the callback to trigger once the texture is ready
  48722. * @param onError defines the callback to trigger in case of error
  48723. */
  48724. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48725. /**
  48726. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48727. * @param data contains the texture data
  48728. * @param texture defines the BabylonJS internal texture
  48729. * @param callback defines the method to call once ready to upload
  48730. */
  48731. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48732. }
  48733. }
  48734. declare module BABYLON {
  48735. /**
  48736. * Options for the default xr helper
  48737. */
  48738. export class WebXRDefaultExperienceOptions {
  48739. /**
  48740. * Floor meshes that should be used for teleporting
  48741. */
  48742. floorMeshes: Array<AbstractMesh>;
  48743. }
  48744. /**
  48745. * Default experience which provides a similar setup to the previous webVRExperience
  48746. */
  48747. export class WebXRDefaultExperience {
  48748. /**
  48749. * Base experience
  48750. */
  48751. baseExperience: WebXRExperienceHelper;
  48752. /**
  48753. * Input experience extension
  48754. */
  48755. input: WebXRInput;
  48756. /**
  48757. * Loads the controller models
  48758. */
  48759. controllerModelLoader: WebXRControllerModelLoader;
  48760. /**
  48761. * Enables laser pointer and selection
  48762. */
  48763. pointerSelection: WebXRControllerPointerSelection;
  48764. /**
  48765. * Enables teleportation
  48766. */
  48767. teleportation: WebXRControllerTeleportation;
  48768. /**
  48769. * Enables ui for enetering/exiting xr
  48770. */
  48771. enterExitUI: WebXREnterExitUI;
  48772. /**
  48773. * Default output canvas xr should render to
  48774. */
  48775. outputCanvas: WebXRManagedOutputCanvas;
  48776. /**
  48777. * Creates the default xr experience
  48778. * @param scene scene
  48779. * @param options options for basic configuration
  48780. * @returns resulting WebXRDefaultExperience
  48781. */
  48782. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48783. private constructor();
  48784. /**
  48785. * DIsposes of the experience helper
  48786. */
  48787. dispose(): void;
  48788. }
  48789. }
  48790. declare module BABYLON {
  48791. /** @hidden */
  48792. export var _forceSceneHelpersToBundle: boolean;
  48793. interface Scene {
  48794. /**
  48795. * Creates a default light for the scene.
  48796. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48797. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48798. */
  48799. createDefaultLight(replace?: boolean): void;
  48800. /**
  48801. * Creates a default camera for the scene.
  48802. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48803. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48804. * @param replace has default false, when true replaces the active camera in the scene
  48805. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48806. */
  48807. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48808. /**
  48809. * Creates a default camera and a default light.
  48810. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48811. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48812. * @param replace has the default false, when true replaces the active camera/light in the scene
  48813. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48814. */
  48815. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48816. /**
  48817. * Creates a new sky box
  48818. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48819. * @param environmentTexture defines the texture to use as environment texture
  48820. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48821. * @param scale defines the overall scale of the skybox
  48822. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48823. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48824. * @returns a new mesh holding the sky box
  48825. */
  48826. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48827. /**
  48828. * Creates a new environment
  48829. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48830. * @param options defines the options you can use to configure the environment
  48831. * @returns the new EnvironmentHelper
  48832. */
  48833. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48834. /**
  48835. * Creates a new VREXperienceHelper
  48836. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48837. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48838. * @returns a new VREXperienceHelper
  48839. */
  48840. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48841. /**
  48842. * Creates a new WebXRDefaultExperience
  48843. * @see http://doc.babylonjs.com/how_to/webxr
  48844. * @param options experience options
  48845. * @returns a promise for a new WebXRDefaultExperience
  48846. */
  48847. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48848. }
  48849. }
  48850. declare module BABYLON {
  48851. /**
  48852. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48853. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48854. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48855. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48856. */
  48857. export class VideoDome extends TransformNode {
  48858. /**
  48859. * Define the video source as a Monoscopic panoramic 360 video.
  48860. */
  48861. static readonly MODE_MONOSCOPIC: number;
  48862. /**
  48863. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48864. */
  48865. static readonly MODE_TOPBOTTOM: number;
  48866. /**
  48867. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48868. */
  48869. static readonly MODE_SIDEBYSIDE: number;
  48870. private _halfDome;
  48871. private _useDirectMapping;
  48872. /**
  48873. * The video texture being displayed on the sphere
  48874. */
  48875. protected _videoTexture: VideoTexture;
  48876. /**
  48877. * Gets the video texture being displayed on the sphere
  48878. */
  48879. readonly videoTexture: VideoTexture;
  48880. /**
  48881. * The skybox material
  48882. */
  48883. protected _material: BackgroundMaterial;
  48884. /**
  48885. * The surface used for the skybox
  48886. */
  48887. protected _mesh: Mesh;
  48888. /**
  48889. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48890. */
  48891. private _halfDomeMask;
  48892. /**
  48893. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48894. * Also see the options.resolution property.
  48895. */
  48896. fovMultiplier: number;
  48897. private _videoMode;
  48898. /**
  48899. * Gets or set the current video mode for the video. It can be:
  48900. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48901. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48902. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48903. */
  48904. videoMode: number;
  48905. /**
  48906. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48907. *
  48908. */
  48909. /**
  48910. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48911. */
  48912. halfDome: boolean;
  48913. /**
  48914. * Oberserver used in Stereoscopic VR Mode.
  48915. */
  48916. private _onBeforeCameraRenderObserver;
  48917. /**
  48918. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48919. * @param name Element's name, child elements will append suffixes for their own names.
  48920. * @param urlsOrVideo defines the url(s) or the video element to use
  48921. * @param options An object containing optional or exposed sub element properties
  48922. */
  48923. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48924. resolution?: number;
  48925. clickToPlay?: boolean;
  48926. autoPlay?: boolean;
  48927. loop?: boolean;
  48928. size?: number;
  48929. poster?: string;
  48930. faceForward?: boolean;
  48931. useDirectMapping?: boolean;
  48932. halfDomeMode?: boolean;
  48933. }, scene: Scene);
  48934. private _changeVideoMode;
  48935. /**
  48936. * Releases resources associated with this node.
  48937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48939. */
  48940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48941. }
  48942. }
  48943. declare module BABYLON {
  48944. /**
  48945. * This class can be used to get instrumentation data from a Babylon engine
  48946. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48947. */
  48948. export class EngineInstrumentation implements IDisposable {
  48949. /**
  48950. * Define the instrumented engine.
  48951. */
  48952. engine: Engine;
  48953. private _captureGPUFrameTime;
  48954. private _gpuFrameTimeToken;
  48955. private _gpuFrameTime;
  48956. private _captureShaderCompilationTime;
  48957. private _shaderCompilationTime;
  48958. private _onBeginFrameObserver;
  48959. private _onEndFrameObserver;
  48960. private _onBeforeShaderCompilationObserver;
  48961. private _onAfterShaderCompilationObserver;
  48962. /**
  48963. * Gets the perf counter used for GPU frame time
  48964. */
  48965. readonly gpuFrameTimeCounter: PerfCounter;
  48966. /**
  48967. * Gets the GPU frame time capture status
  48968. */
  48969. /**
  48970. * Enable or disable the GPU frame time capture
  48971. */
  48972. captureGPUFrameTime: boolean;
  48973. /**
  48974. * Gets the perf counter used for shader compilation time
  48975. */
  48976. readonly shaderCompilationTimeCounter: PerfCounter;
  48977. /**
  48978. * Gets the shader compilation time capture status
  48979. */
  48980. /**
  48981. * Enable or disable the shader compilation time capture
  48982. */
  48983. captureShaderCompilationTime: boolean;
  48984. /**
  48985. * Instantiates a new engine instrumentation.
  48986. * This class can be used to get instrumentation data from a Babylon engine
  48987. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48988. * @param engine Defines the engine to instrument
  48989. */
  48990. constructor(
  48991. /**
  48992. * Define the instrumented engine.
  48993. */
  48994. engine: Engine);
  48995. /**
  48996. * Dispose and release associated resources.
  48997. */
  48998. dispose(): void;
  48999. }
  49000. }
  49001. declare module BABYLON {
  49002. /**
  49003. * This class can be used to get instrumentation data from a Babylon engine
  49004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49005. */
  49006. export class SceneInstrumentation implements IDisposable {
  49007. /**
  49008. * Defines the scene to instrument
  49009. */
  49010. scene: Scene;
  49011. private _captureActiveMeshesEvaluationTime;
  49012. private _activeMeshesEvaluationTime;
  49013. private _captureRenderTargetsRenderTime;
  49014. private _renderTargetsRenderTime;
  49015. private _captureFrameTime;
  49016. private _frameTime;
  49017. private _captureRenderTime;
  49018. private _renderTime;
  49019. private _captureInterFrameTime;
  49020. private _interFrameTime;
  49021. private _captureParticlesRenderTime;
  49022. private _particlesRenderTime;
  49023. private _captureSpritesRenderTime;
  49024. private _spritesRenderTime;
  49025. private _capturePhysicsTime;
  49026. private _physicsTime;
  49027. private _captureAnimationsTime;
  49028. private _animationsTime;
  49029. private _captureCameraRenderTime;
  49030. private _cameraRenderTime;
  49031. private _onBeforeActiveMeshesEvaluationObserver;
  49032. private _onAfterActiveMeshesEvaluationObserver;
  49033. private _onBeforeRenderTargetsRenderObserver;
  49034. private _onAfterRenderTargetsRenderObserver;
  49035. private _onAfterRenderObserver;
  49036. private _onBeforeDrawPhaseObserver;
  49037. private _onAfterDrawPhaseObserver;
  49038. private _onBeforeAnimationsObserver;
  49039. private _onBeforeParticlesRenderingObserver;
  49040. private _onAfterParticlesRenderingObserver;
  49041. private _onBeforeSpritesRenderingObserver;
  49042. private _onAfterSpritesRenderingObserver;
  49043. private _onBeforePhysicsObserver;
  49044. private _onAfterPhysicsObserver;
  49045. private _onAfterAnimationsObserver;
  49046. private _onBeforeCameraRenderObserver;
  49047. private _onAfterCameraRenderObserver;
  49048. /**
  49049. * Gets the perf counter used for active meshes evaluation time
  49050. */
  49051. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49052. /**
  49053. * Gets the active meshes evaluation time capture status
  49054. */
  49055. /**
  49056. * Enable or disable the active meshes evaluation time capture
  49057. */
  49058. captureActiveMeshesEvaluationTime: boolean;
  49059. /**
  49060. * Gets the perf counter used for render targets render time
  49061. */
  49062. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49063. /**
  49064. * Gets the render targets render time capture status
  49065. */
  49066. /**
  49067. * Enable or disable the render targets render time capture
  49068. */
  49069. captureRenderTargetsRenderTime: boolean;
  49070. /**
  49071. * Gets the perf counter used for particles render time
  49072. */
  49073. readonly particlesRenderTimeCounter: PerfCounter;
  49074. /**
  49075. * Gets the particles render time capture status
  49076. */
  49077. /**
  49078. * Enable or disable the particles render time capture
  49079. */
  49080. captureParticlesRenderTime: boolean;
  49081. /**
  49082. * Gets the perf counter used for sprites render time
  49083. */
  49084. readonly spritesRenderTimeCounter: PerfCounter;
  49085. /**
  49086. * Gets the sprites render time capture status
  49087. */
  49088. /**
  49089. * Enable or disable the sprites render time capture
  49090. */
  49091. captureSpritesRenderTime: boolean;
  49092. /**
  49093. * Gets the perf counter used for physics time
  49094. */
  49095. readonly physicsTimeCounter: PerfCounter;
  49096. /**
  49097. * Gets the physics time capture status
  49098. */
  49099. /**
  49100. * Enable or disable the physics time capture
  49101. */
  49102. capturePhysicsTime: boolean;
  49103. /**
  49104. * Gets the perf counter used for animations time
  49105. */
  49106. readonly animationsTimeCounter: PerfCounter;
  49107. /**
  49108. * Gets the animations time capture status
  49109. */
  49110. /**
  49111. * Enable or disable the animations time capture
  49112. */
  49113. captureAnimationsTime: boolean;
  49114. /**
  49115. * Gets the perf counter used for frame time capture
  49116. */
  49117. readonly frameTimeCounter: PerfCounter;
  49118. /**
  49119. * Gets the frame time capture status
  49120. */
  49121. /**
  49122. * Enable or disable the frame time capture
  49123. */
  49124. captureFrameTime: boolean;
  49125. /**
  49126. * Gets the perf counter used for inter-frames time capture
  49127. */
  49128. readonly interFrameTimeCounter: PerfCounter;
  49129. /**
  49130. * Gets the inter-frames time capture status
  49131. */
  49132. /**
  49133. * Enable or disable the inter-frames time capture
  49134. */
  49135. captureInterFrameTime: boolean;
  49136. /**
  49137. * Gets the perf counter used for render time capture
  49138. */
  49139. readonly renderTimeCounter: PerfCounter;
  49140. /**
  49141. * Gets the render time capture status
  49142. */
  49143. /**
  49144. * Enable or disable the render time capture
  49145. */
  49146. captureRenderTime: boolean;
  49147. /**
  49148. * Gets the perf counter used for camera render time capture
  49149. */
  49150. readonly cameraRenderTimeCounter: PerfCounter;
  49151. /**
  49152. * Gets the camera render time capture status
  49153. */
  49154. /**
  49155. * Enable or disable the camera render time capture
  49156. */
  49157. captureCameraRenderTime: boolean;
  49158. /**
  49159. * Gets the perf counter used for draw calls
  49160. */
  49161. readonly drawCallsCounter: PerfCounter;
  49162. /**
  49163. * Instantiates a new scene instrumentation.
  49164. * This class can be used to get instrumentation data from a Babylon engine
  49165. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49166. * @param scene Defines the scene to instrument
  49167. */
  49168. constructor(
  49169. /**
  49170. * Defines the scene to instrument
  49171. */
  49172. scene: Scene);
  49173. /**
  49174. * Dispose and release associated resources.
  49175. */
  49176. dispose(): void;
  49177. }
  49178. }
  49179. declare module BABYLON {
  49180. /** @hidden */
  49181. export var glowMapGenerationPixelShader: {
  49182. name: string;
  49183. shader: string;
  49184. };
  49185. }
  49186. declare module BABYLON {
  49187. /** @hidden */
  49188. export var glowMapGenerationVertexShader: {
  49189. name: string;
  49190. shader: string;
  49191. };
  49192. }
  49193. declare module BABYLON {
  49194. /**
  49195. * Effect layer options. This helps customizing the behaviour
  49196. * of the effect layer.
  49197. */
  49198. export interface IEffectLayerOptions {
  49199. /**
  49200. * Multiplication factor apply to the canvas size to compute the render target size
  49201. * used to generated the objects (the smaller the faster).
  49202. */
  49203. mainTextureRatio: number;
  49204. /**
  49205. * Enforces a fixed size texture to ensure effect stability across devices.
  49206. */
  49207. mainTextureFixedSize?: number;
  49208. /**
  49209. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49210. */
  49211. alphaBlendingMode: number;
  49212. /**
  49213. * The camera attached to the layer.
  49214. */
  49215. camera: Nullable<Camera>;
  49216. /**
  49217. * The rendering group to draw the layer in.
  49218. */
  49219. renderingGroupId: number;
  49220. }
  49221. /**
  49222. * The effect layer Helps adding post process effect blended with the main pass.
  49223. *
  49224. * This can be for instance use to generate glow or higlight effects on the scene.
  49225. *
  49226. * The effect layer class can not be used directly and is intented to inherited from to be
  49227. * customized per effects.
  49228. */
  49229. export abstract class EffectLayer {
  49230. private _vertexBuffers;
  49231. private _indexBuffer;
  49232. private _cachedDefines;
  49233. private _effectLayerMapGenerationEffect;
  49234. private _effectLayerOptions;
  49235. private _mergeEffect;
  49236. protected _scene: Scene;
  49237. protected _engine: Engine;
  49238. protected _maxSize: number;
  49239. protected _mainTextureDesiredSize: ISize;
  49240. protected _mainTexture: RenderTargetTexture;
  49241. protected _shouldRender: boolean;
  49242. protected _postProcesses: PostProcess[];
  49243. protected _textures: BaseTexture[];
  49244. protected _emissiveTextureAndColor: {
  49245. texture: Nullable<BaseTexture>;
  49246. color: Color4;
  49247. };
  49248. /**
  49249. * The name of the layer
  49250. */
  49251. name: string;
  49252. /**
  49253. * The clear color of the texture used to generate the glow map.
  49254. */
  49255. neutralColor: Color4;
  49256. /**
  49257. * Specifies wether the highlight layer is enabled or not.
  49258. */
  49259. isEnabled: boolean;
  49260. /**
  49261. * Gets the camera attached to the layer.
  49262. */
  49263. readonly camera: Nullable<Camera>;
  49264. /**
  49265. * Gets the rendering group id the layer should render in.
  49266. */
  49267. renderingGroupId: number;
  49268. /**
  49269. * An event triggered when the effect layer has been disposed.
  49270. */
  49271. onDisposeObservable: Observable<EffectLayer>;
  49272. /**
  49273. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49274. */
  49275. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49276. /**
  49277. * An event triggered when the generated texture is being merged in the scene.
  49278. */
  49279. onBeforeComposeObservable: Observable<EffectLayer>;
  49280. /**
  49281. * An event triggered when the generated texture has been merged in the scene.
  49282. */
  49283. onAfterComposeObservable: Observable<EffectLayer>;
  49284. /**
  49285. * An event triggered when the efffect layer changes its size.
  49286. */
  49287. onSizeChangedObservable: Observable<EffectLayer>;
  49288. /** @hidden */
  49289. static _SceneComponentInitialization: (scene: Scene) => void;
  49290. /**
  49291. * Instantiates a new effect Layer and references it in the scene.
  49292. * @param name The name of the layer
  49293. * @param scene The scene to use the layer in
  49294. */
  49295. constructor(
  49296. /** The Friendly of the effect in the scene */
  49297. name: string, scene: Scene);
  49298. /**
  49299. * Get the effect name of the layer.
  49300. * @return The effect name
  49301. */
  49302. abstract getEffectName(): string;
  49303. /**
  49304. * Checks for the readiness of the element composing the layer.
  49305. * @param subMesh the mesh to check for
  49306. * @param useInstances specify wether or not to use instances to render the mesh
  49307. * @return true if ready otherwise, false
  49308. */
  49309. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49310. /**
  49311. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49312. * @returns true if the effect requires stencil during the main canvas render pass.
  49313. */
  49314. abstract needStencil(): boolean;
  49315. /**
  49316. * Create the merge effect. This is the shader use to blit the information back
  49317. * to the main canvas at the end of the scene rendering.
  49318. * @returns The effect containing the shader used to merge the effect on the main canvas
  49319. */
  49320. protected abstract _createMergeEffect(): Effect;
  49321. /**
  49322. * Creates the render target textures and post processes used in the effect layer.
  49323. */
  49324. protected abstract _createTextureAndPostProcesses(): void;
  49325. /**
  49326. * Implementation specific of rendering the generating effect on the main canvas.
  49327. * @param effect The effect used to render through
  49328. */
  49329. protected abstract _internalRender(effect: Effect): void;
  49330. /**
  49331. * Sets the required values for both the emissive texture and and the main color.
  49332. */
  49333. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49334. /**
  49335. * Free any resources and references associated to a mesh.
  49336. * Internal use
  49337. * @param mesh The mesh to free.
  49338. */
  49339. abstract _disposeMesh(mesh: Mesh): void;
  49340. /**
  49341. * Serializes this layer (Glow or Highlight for example)
  49342. * @returns a serialized layer object
  49343. */
  49344. abstract serialize?(): any;
  49345. /**
  49346. * Initializes the effect layer with the required options.
  49347. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49348. */
  49349. protected _init(options: Partial<IEffectLayerOptions>): void;
  49350. /**
  49351. * Generates the index buffer of the full screen quad blending to the main canvas.
  49352. */
  49353. private _generateIndexBuffer;
  49354. /**
  49355. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49356. */
  49357. private _generateVertexBuffer;
  49358. /**
  49359. * Sets the main texture desired size which is the closest power of two
  49360. * of the engine canvas size.
  49361. */
  49362. private _setMainTextureSize;
  49363. /**
  49364. * Creates the main texture for the effect layer.
  49365. */
  49366. protected _createMainTexture(): void;
  49367. /**
  49368. * Adds specific effects defines.
  49369. * @param defines The defines to add specifics to.
  49370. */
  49371. protected _addCustomEffectDefines(defines: string[]): void;
  49372. /**
  49373. * Checks for the readiness of the element composing the layer.
  49374. * @param subMesh the mesh to check for
  49375. * @param useInstances specify wether or not to use instances to render the mesh
  49376. * @param emissiveTexture the associated emissive texture used to generate the glow
  49377. * @return true if ready otherwise, false
  49378. */
  49379. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49380. /**
  49381. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49382. */
  49383. render(): void;
  49384. /**
  49385. * Determine if a given mesh will be used in the current effect.
  49386. * @param mesh mesh to test
  49387. * @returns true if the mesh will be used
  49388. */
  49389. hasMesh(mesh: AbstractMesh): boolean;
  49390. /**
  49391. * Returns true if the layer contains information to display, otherwise false.
  49392. * @returns true if the glow layer should be rendered
  49393. */
  49394. shouldRender(): boolean;
  49395. /**
  49396. * Returns true if the mesh should render, otherwise false.
  49397. * @param mesh The mesh to render
  49398. * @returns true if it should render otherwise false
  49399. */
  49400. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49401. /**
  49402. * Returns true if the mesh can be rendered, otherwise false.
  49403. * @param mesh The mesh to render
  49404. * @param material The material used on the mesh
  49405. * @returns true if it can be rendered otherwise false
  49406. */
  49407. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49408. /**
  49409. * Returns true if the mesh should render, otherwise false.
  49410. * @param mesh The mesh to render
  49411. * @returns true if it should render otherwise false
  49412. */
  49413. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49414. /**
  49415. * Renders the submesh passed in parameter to the generation map.
  49416. */
  49417. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49418. /**
  49419. * Rebuild the required buffers.
  49420. * @hidden Internal use only.
  49421. */
  49422. _rebuild(): void;
  49423. /**
  49424. * Dispose only the render target textures and post process.
  49425. */
  49426. private _disposeTextureAndPostProcesses;
  49427. /**
  49428. * Dispose the highlight layer and free resources.
  49429. */
  49430. dispose(): void;
  49431. /**
  49432. * Gets the class name of the effect layer
  49433. * @returns the string with the class name of the effect layer
  49434. */
  49435. getClassName(): string;
  49436. /**
  49437. * Creates an effect layer from parsed effect layer data
  49438. * @param parsedEffectLayer defines effect layer data
  49439. * @param scene defines the current scene
  49440. * @param rootUrl defines the root URL containing the effect layer information
  49441. * @returns a parsed effect Layer
  49442. */
  49443. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49444. }
  49445. }
  49446. declare module BABYLON {
  49447. interface AbstractScene {
  49448. /**
  49449. * The list of effect layers (highlights/glow) added to the scene
  49450. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49451. * @see http://doc.babylonjs.com/how_to/glow_layer
  49452. */
  49453. effectLayers: Array<EffectLayer>;
  49454. /**
  49455. * Removes the given effect layer from this scene.
  49456. * @param toRemove defines the effect layer to remove
  49457. * @returns the index of the removed effect layer
  49458. */
  49459. removeEffectLayer(toRemove: EffectLayer): number;
  49460. /**
  49461. * Adds the given effect layer to this scene
  49462. * @param newEffectLayer defines the effect layer to add
  49463. */
  49464. addEffectLayer(newEffectLayer: EffectLayer): void;
  49465. }
  49466. /**
  49467. * Defines the layer scene component responsible to manage any effect layers
  49468. * in a given scene.
  49469. */
  49470. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49471. /**
  49472. * The component name helpfull to identify the component in the list of scene components.
  49473. */
  49474. readonly name: string;
  49475. /**
  49476. * The scene the component belongs to.
  49477. */
  49478. scene: Scene;
  49479. private _engine;
  49480. private _renderEffects;
  49481. private _needStencil;
  49482. private _previousStencilState;
  49483. /**
  49484. * Creates a new instance of the component for the given scene
  49485. * @param scene Defines the scene to register the component in
  49486. */
  49487. constructor(scene: Scene);
  49488. /**
  49489. * Registers the component in a given scene
  49490. */
  49491. register(): void;
  49492. /**
  49493. * Rebuilds the elements related to this component in case of
  49494. * context lost for instance.
  49495. */
  49496. rebuild(): void;
  49497. /**
  49498. * Serializes the component data to the specified json object
  49499. * @param serializationObject The object to serialize to
  49500. */
  49501. serialize(serializationObject: any): void;
  49502. /**
  49503. * Adds all the elements from the container to the scene
  49504. * @param container the container holding the elements
  49505. */
  49506. addFromContainer(container: AbstractScene): void;
  49507. /**
  49508. * Removes all the elements in the container from the scene
  49509. * @param container contains the elements to remove
  49510. * @param dispose if the removed element should be disposed (default: false)
  49511. */
  49512. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49513. /**
  49514. * Disposes the component and the associated ressources.
  49515. */
  49516. dispose(): void;
  49517. private _isReadyForMesh;
  49518. private _renderMainTexture;
  49519. private _setStencil;
  49520. private _setStencilBack;
  49521. private _draw;
  49522. private _drawCamera;
  49523. private _drawRenderingGroup;
  49524. }
  49525. }
  49526. declare module BABYLON {
  49527. /** @hidden */
  49528. export var glowMapMergePixelShader: {
  49529. name: string;
  49530. shader: string;
  49531. };
  49532. }
  49533. declare module BABYLON {
  49534. /** @hidden */
  49535. export var glowMapMergeVertexShader: {
  49536. name: string;
  49537. shader: string;
  49538. };
  49539. }
  49540. declare module BABYLON {
  49541. interface AbstractScene {
  49542. /**
  49543. * Return a the first highlight layer of the scene with a given name.
  49544. * @param name The name of the highlight layer to look for.
  49545. * @return The highlight layer if found otherwise null.
  49546. */
  49547. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49548. }
  49549. /**
  49550. * Glow layer options. This helps customizing the behaviour
  49551. * of the glow layer.
  49552. */
  49553. export interface IGlowLayerOptions {
  49554. /**
  49555. * Multiplication factor apply to the canvas size to compute the render target size
  49556. * used to generated the glowing objects (the smaller the faster).
  49557. */
  49558. mainTextureRatio: number;
  49559. /**
  49560. * Enforces a fixed size texture to ensure resize independant blur.
  49561. */
  49562. mainTextureFixedSize?: number;
  49563. /**
  49564. * How big is the kernel of the blur texture.
  49565. */
  49566. blurKernelSize: number;
  49567. /**
  49568. * The camera attached to the layer.
  49569. */
  49570. camera: Nullable<Camera>;
  49571. /**
  49572. * Enable MSAA by chosing the number of samples.
  49573. */
  49574. mainTextureSamples?: number;
  49575. /**
  49576. * The rendering group to draw the layer in.
  49577. */
  49578. renderingGroupId: number;
  49579. }
  49580. /**
  49581. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49582. *
  49583. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49584. * glowy meshes to your scene.
  49585. *
  49586. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49587. */
  49588. export class GlowLayer extends EffectLayer {
  49589. /**
  49590. * Effect Name of the layer.
  49591. */
  49592. static readonly EffectName: string;
  49593. /**
  49594. * The default blur kernel size used for the glow.
  49595. */
  49596. static DefaultBlurKernelSize: number;
  49597. /**
  49598. * The default texture size ratio used for the glow.
  49599. */
  49600. static DefaultTextureRatio: number;
  49601. /**
  49602. * Sets the kernel size of the blur.
  49603. */
  49604. /**
  49605. * Gets the kernel size of the blur.
  49606. */
  49607. blurKernelSize: number;
  49608. /**
  49609. * Sets the glow intensity.
  49610. */
  49611. /**
  49612. * Gets the glow intensity.
  49613. */
  49614. intensity: number;
  49615. private _options;
  49616. private _intensity;
  49617. private _horizontalBlurPostprocess1;
  49618. private _verticalBlurPostprocess1;
  49619. private _horizontalBlurPostprocess2;
  49620. private _verticalBlurPostprocess2;
  49621. private _blurTexture1;
  49622. private _blurTexture2;
  49623. private _postProcesses1;
  49624. private _postProcesses2;
  49625. private _includedOnlyMeshes;
  49626. private _excludedMeshes;
  49627. /**
  49628. * Callback used to let the user override the color selection on a per mesh basis
  49629. */
  49630. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49631. /**
  49632. * Callback used to let the user override the texture selection on a per mesh basis
  49633. */
  49634. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49635. /**
  49636. * Instantiates a new glow Layer and references it to the scene.
  49637. * @param name The name of the layer
  49638. * @param scene The scene to use the layer in
  49639. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49640. */
  49641. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49642. /**
  49643. * Get the effect name of the layer.
  49644. * @return The effect name
  49645. */
  49646. getEffectName(): string;
  49647. /**
  49648. * Create the merge effect. This is the shader use to blit the information back
  49649. * to the main canvas at the end of the scene rendering.
  49650. */
  49651. protected _createMergeEffect(): Effect;
  49652. /**
  49653. * Creates the render target textures and post processes used in the glow layer.
  49654. */
  49655. protected _createTextureAndPostProcesses(): void;
  49656. /**
  49657. * Checks for the readiness of the element composing the layer.
  49658. * @param subMesh the mesh to check for
  49659. * @param useInstances specify wether or not to use instances to render the mesh
  49660. * @param emissiveTexture the associated emissive texture used to generate the glow
  49661. * @return true if ready otherwise, false
  49662. */
  49663. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49664. /**
  49665. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49666. */
  49667. needStencil(): boolean;
  49668. /**
  49669. * Returns true if the mesh can be rendered, otherwise false.
  49670. * @param mesh The mesh to render
  49671. * @param material The material used on the mesh
  49672. * @returns true if it can be rendered otherwise false
  49673. */
  49674. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49675. /**
  49676. * Implementation specific of rendering the generating effect on the main canvas.
  49677. * @param effect The effect used to render through
  49678. */
  49679. protected _internalRender(effect: Effect): void;
  49680. /**
  49681. * Sets the required values for both the emissive texture and and the main color.
  49682. */
  49683. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49684. /**
  49685. * Returns true if the mesh should render, otherwise false.
  49686. * @param mesh The mesh to render
  49687. * @returns true if it should render otherwise false
  49688. */
  49689. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49690. /**
  49691. * Adds specific effects defines.
  49692. * @param defines The defines to add specifics to.
  49693. */
  49694. protected _addCustomEffectDefines(defines: string[]): void;
  49695. /**
  49696. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49697. * @param mesh The mesh to exclude from the glow layer
  49698. */
  49699. addExcludedMesh(mesh: Mesh): void;
  49700. /**
  49701. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49702. * @param mesh The mesh to remove
  49703. */
  49704. removeExcludedMesh(mesh: Mesh): void;
  49705. /**
  49706. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49707. * @param mesh The mesh to include in the glow layer
  49708. */
  49709. addIncludedOnlyMesh(mesh: Mesh): void;
  49710. /**
  49711. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49712. * @param mesh The mesh to remove
  49713. */
  49714. removeIncludedOnlyMesh(mesh: Mesh): void;
  49715. /**
  49716. * Determine if a given mesh will be used in the glow layer
  49717. * @param mesh The mesh to test
  49718. * @returns true if the mesh will be highlighted by the current glow layer
  49719. */
  49720. hasMesh(mesh: AbstractMesh): boolean;
  49721. /**
  49722. * Free any resources and references associated to a mesh.
  49723. * Internal use
  49724. * @param mesh The mesh to free.
  49725. * @hidden
  49726. */
  49727. _disposeMesh(mesh: Mesh): void;
  49728. /**
  49729. * Gets the class name of the effect layer
  49730. * @returns the string with the class name of the effect layer
  49731. */
  49732. getClassName(): string;
  49733. /**
  49734. * Serializes this glow layer
  49735. * @returns a serialized glow layer object
  49736. */
  49737. serialize(): any;
  49738. /**
  49739. * Creates a Glow Layer from parsed glow layer data
  49740. * @param parsedGlowLayer defines glow layer data
  49741. * @param scene defines the current scene
  49742. * @param rootUrl defines the root URL containing the glow layer information
  49743. * @returns a parsed Glow Layer
  49744. */
  49745. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49746. }
  49747. }
  49748. declare module BABYLON {
  49749. /** @hidden */
  49750. export var glowBlurPostProcessPixelShader: {
  49751. name: string;
  49752. shader: string;
  49753. };
  49754. }
  49755. declare module BABYLON {
  49756. interface AbstractScene {
  49757. /**
  49758. * Return a the first highlight layer of the scene with a given name.
  49759. * @param name The name of the highlight layer to look for.
  49760. * @return The highlight layer if found otherwise null.
  49761. */
  49762. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49763. }
  49764. /**
  49765. * Highlight layer options. This helps customizing the behaviour
  49766. * of the highlight layer.
  49767. */
  49768. export interface IHighlightLayerOptions {
  49769. /**
  49770. * Multiplication factor apply to the canvas size to compute the render target size
  49771. * used to generated the glowing objects (the smaller the faster).
  49772. */
  49773. mainTextureRatio: number;
  49774. /**
  49775. * Enforces a fixed size texture to ensure resize independant blur.
  49776. */
  49777. mainTextureFixedSize?: number;
  49778. /**
  49779. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49780. * of the picture to blur (the smaller the faster).
  49781. */
  49782. blurTextureSizeRatio: number;
  49783. /**
  49784. * How big in texel of the blur texture is the vertical blur.
  49785. */
  49786. blurVerticalSize: number;
  49787. /**
  49788. * How big in texel of the blur texture is the horizontal blur.
  49789. */
  49790. blurHorizontalSize: number;
  49791. /**
  49792. * Alpha blending mode used to apply the blur. Default is combine.
  49793. */
  49794. alphaBlendingMode: number;
  49795. /**
  49796. * The camera attached to the layer.
  49797. */
  49798. camera: Nullable<Camera>;
  49799. /**
  49800. * Should we display highlight as a solid stroke?
  49801. */
  49802. isStroke?: boolean;
  49803. /**
  49804. * The rendering group to draw the layer in.
  49805. */
  49806. renderingGroupId: number;
  49807. }
  49808. /**
  49809. * The highlight layer Helps adding a glow effect around a mesh.
  49810. *
  49811. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49812. * glowy meshes to your scene.
  49813. *
  49814. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49815. */
  49816. export class HighlightLayer extends EffectLayer {
  49817. name: string;
  49818. /**
  49819. * Effect Name of the highlight layer.
  49820. */
  49821. static readonly EffectName: string;
  49822. /**
  49823. * The neutral color used during the preparation of the glow effect.
  49824. * This is black by default as the blend operation is a blend operation.
  49825. */
  49826. static NeutralColor: Color4;
  49827. /**
  49828. * Stencil value used for glowing meshes.
  49829. */
  49830. static GlowingMeshStencilReference: number;
  49831. /**
  49832. * Stencil value used for the other meshes in the scene.
  49833. */
  49834. static NormalMeshStencilReference: number;
  49835. /**
  49836. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49837. */
  49838. innerGlow: boolean;
  49839. /**
  49840. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49841. */
  49842. outerGlow: boolean;
  49843. /**
  49844. * Specifies the horizontal size of the blur.
  49845. */
  49846. /**
  49847. * Gets the horizontal size of the blur.
  49848. */
  49849. blurHorizontalSize: number;
  49850. /**
  49851. * Specifies the vertical size of the blur.
  49852. */
  49853. /**
  49854. * Gets the vertical size of the blur.
  49855. */
  49856. blurVerticalSize: number;
  49857. /**
  49858. * An event triggered when the highlight layer is being blurred.
  49859. */
  49860. onBeforeBlurObservable: Observable<HighlightLayer>;
  49861. /**
  49862. * An event triggered when the highlight layer has been blurred.
  49863. */
  49864. onAfterBlurObservable: Observable<HighlightLayer>;
  49865. private _instanceGlowingMeshStencilReference;
  49866. private _options;
  49867. private _downSamplePostprocess;
  49868. private _horizontalBlurPostprocess;
  49869. private _verticalBlurPostprocess;
  49870. private _blurTexture;
  49871. private _meshes;
  49872. private _excludedMeshes;
  49873. /**
  49874. * Instantiates a new highlight Layer and references it to the scene..
  49875. * @param name The name of the layer
  49876. * @param scene The scene to use the layer in
  49877. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49878. */
  49879. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49880. /**
  49881. * Get the effect name of the layer.
  49882. * @return The effect name
  49883. */
  49884. getEffectName(): string;
  49885. /**
  49886. * Create the merge effect. This is the shader use to blit the information back
  49887. * to the main canvas at the end of the scene rendering.
  49888. */
  49889. protected _createMergeEffect(): Effect;
  49890. /**
  49891. * Creates the render target textures and post processes used in the highlight layer.
  49892. */
  49893. protected _createTextureAndPostProcesses(): void;
  49894. /**
  49895. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49896. */
  49897. needStencil(): boolean;
  49898. /**
  49899. * Checks for the readiness of the element composing the layer.
  49900. * @param subMesh the mesh to check for
  49901. * @param useInstances specify wether or not to use instances to render the mesh
  49902. * @param emissiveTexture the associated emissive texture used to generate the glow
  49903. * @return true if ready otherwise, false
  49904. */
  49905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49906. /**
  49907. * Implementation specific of rendering the generating effect on the main canvas.
  49908. * @param effect The effect used to render through
  49909. */
  49910. protected _internalRender(effect: Effect): void;
  49911. /**
  49912. * Returns true if the layer contains information to display, otherwise false.
  49913. */
  49914. shouldRender(): boolean;
  49915. /**
  49916. * Returns true if the mesh should render, otherwise false.
  49917. * @param mesh The mesh to render
  49918. * @returns true if it should render otherwise false
  49919. */
  49920. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49921. /**
  49922. * Sets the required values for both the emissive texture and and the main color.
  49923. */
  49924. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49925. /**
  49926. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49927. * @param mesh The mesh to exclude from the highlight layer
  49928. */
  49929. addExcludedMesh(mesh: Mesh): void;
  49930. /**
  49931. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49932. * @param mesh The mesh to highlight
  49933. */
  49934. removeExcludedMesh(mesh: Mesh): void;
  49935. /**
  49936. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49937. * @param mesh mesh to test
  49938. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49939. */
  49940. hasMesh(mesh: AbstractMesh): boolean;
  49941. /**
  49942. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49943. * @param mesh The mesh to highlight
  49944. * @param color The color of the highlight
  49945. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49946. */
  49947. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49948. /**
  49949. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49950. * @param mesh The mesh to highlight
  49951. */
  49952. removeMesh(mesh: Mesh): void;
  49953. /**
  49954. * Force the stencil to the normal expected value for none glowing parts
  49955. */
  49956. private _defaultStencilReference;
  49957. /**
  49958. * Free any resources and references associated to a mesh.
  49959. * Internal use
  49960. * @param mesh The mesh to free.
  49961. * @hidden
  49962. */
  49963. _disposeMesh(mesh: Mesh): void;
  49964. /**
  49965. * Dispose the highlight layer and free resources.
  49966. */
  49967. dispose(): void;
  49968. /**
  49969. * Gets the class name of the effect layer
  49970. * @returns the string with the class name of the effect layer
  49971. */
  49972. getClassName(): string;
  49973. /**
  49974. * Serializes this Highlight layer
  49975. * @returns a serialized Highlight layer object
  49976. */
  49977. serialize(): any;
  49978. /**
  49979. * Creates a Highlight layer from parsed Highlight layer data
  49980. * @param parsedHightlightLayer defines the Highlight layer data
  49981. * @param scene defines the current scene
  49982. * @param rootUrl defines the root URL containing the Highlight layer information
  49983. * @returns a parsed Highlight layer
  49984. */
  49985. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49986. }
  49987. }
  49988. declare module BABYLON {
  49989. interface AbstractScene {
  49990. /**
  49991. * The list of layers (background and foreground) of the scene
  49992. */
  49993. layers: Array<Layer>;
  49994. }
  49995. /**
  49996. * Defines the layer scene component responsible to manage any layers
  49997. * in a given scene.
  49998. */
  49999. export class LayerSceneComponent implements ISceneComponent {
  50000. /**
  50001. * The component name helpfull to identify the component in the list of scene components.
  50002. */
  50003. readonly name: string;
  50004. /**
  50005. * The scene the component belongs to.
  50006. */
  50007. scene: Scene;
  50008. private _engine;
  50009. /**
  50010. * Creates a new instance of the component for the given scene
  50011. * @param scene Defines the scene to register the component in
  50012. */
  50013. constructor(scene: Scene);
  50014. /**
  50015. * Registers the component in a given scene
  50016. */
  50017. register(): void;
  50018. /**
  50019. * Rebuilds the elements related to this component in case of
  50020. * context lost for instance.
  50021. */
  50022. rebuild(): void;
  50023. /**
  50024. * Disposes the component and the associated ressources.
  50025. */
  50026. dispose(): void;
  50027. private _draw;
  50028. private _drawCameraPredicate;
  50029. private _drawCameraBackground;
  50030. private _drawCameraForeground;
  50031. private _drawRenderTargetPredicate;
  50032. private _drawRenderTargetBackground;
  50033. private _drawRenderTargetForeground;
  50034. /**
  50035. * Adds all the elements from the container to the scene
  50036. * @param container the container holding the elements
  50037. */
  50038. addFromContainer(container: AbstractScene): void;
  50039. /**
  50040. * Removes all the elements in the container from the scene
  50041. * @param container contains the elements to remove
  50042. * @param dispose if the removed element should be disposed (default: false)
  50043. */
  50044. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50045. }
  50046. }
  50047. declare module BABYLON {
  50048. /** @hidden */
  50049. export var layerPixelShader: {
  50050. name: string;
  50051. shader: string;
  50052. };
  50053. }
  50054. declare module BABYLON {
  50055. /** @hidden */
  50056. export var layerVertexShader: {
  50057. name: string;
  50058. shader: string;
  50059. };
  50060. }
  50061. declare module BABYLON {
  50062. /**
  50063. * This represents a full screen 2d layer.
  50064. * This can be useful to display a picture in the background of your scene for instance.
  50065. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50066. */
  50067. export class Layer {
  50068. /**
  50069. * Define the name of the layer.
  50070. */
  50071. name: string;
  50072. /**
  50073. * Define the texture the layer should display.
  50074. */
  50075. texture: Nullable<Texture>;
  50076. /**
  50077. * Is the layer in background or foreground.
  50078. */
  50079. isBackground: boolean;
  50080. /**
  50081. * Define the color of the layer (instead of texture).
  50082. */
  50083. color: Color4;
  50084. /**
  50085. * Define the scale of the layer in order to zoom in out of the texture.
  50086. */
  50087. scale: Vector2;
  50088. /**
  50089. * Define an offset for the layer in order to shift the texture.
  50090. */
  50091. offset: Vector2;
  50092. /**
  50093. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50094. */
  50095. alphaBlendingMode: number;
  50096. /**
  50097. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50098. * Alpha test will not mix with the background color in case of transparency.
  50099. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50100. */
  50101. alphaTest: boolean;
  50102. /**
  50103. * Define a mask to restrict the layer to only some of the scene cameras.
  50104. */
  50105. layerMask: number;
  50106. /**
  50107. * Define the list of render target the layer is visible into.
  50108. */
  50109. renderTargetTextures: RenderTargetTexture[];
  50110. /**
  50111. * Define if the layer is only used in renderTarget or if it also
  50112. * renders in the main frame buffer of the canvas.
  50113. */
  50114. renderOnlyInRenderTargetTextures: boolean;
  50115. private _scene;
  50116. private _vertexBuffers;
  50117. private _indexBuffer;
  50118. private _effect;
  50119. private _alphaTestEffect;
  50120. /**
  50121. * An event triggered when the layer is disposed.
  50122. */
  50123. onDisposeObservable: Observable<Layer>;
  50124. private _onDisposeObserver;
  50125. /**
  50126. * Back compatibility with callback before the onDisposeObservable existed.
  50127. * The set callback will be triggered when the layer has been disposed.
  50128. */
  50129. onDispose: () => void;
  50130. /**
  50131. * An event triggered before rendering the scene
  50132. */
  50133. onBeforeRenderObservable: Observable<Layer>;
  50134. private _onBeforeRenderObserver;
  50135. /**
  50136. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50137. * The set callback will be triggered just before rendering the layer.
  50138. */
  50139. onBeforeRender: () => void;
  50140. /**
  50141. * An event triggered after rendering the scene
  50142. */
  50143. onAfterRenderObservable: Observable<Layer>;
  50144. private _onAfterRenderObserver;
  50145. /**
  50146. * Back compatibility with callback before the onAfterRenderObservable existed.
  50147. * The set callback will be triggered just after rendering the layer.
  50148. */
  50149. onAfterRender: () => void;
  50150. /**
  50151. * Instantiates a new layer.
  50152. * This represents a full screen 2d layer.
  50153. * This can be useful to display a picture in the background of your scene for instance.
  50154. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50155. * @param name Define the name of the layer in the scene
  50156. * @param imgUrl Define the url of the texture to display in the layer
  50157. * @param scene Define the scene the layer belongs to
  50158. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50159. * @param color Defines a color for the layer
  50160. */
  50161. constructor(
  50162. /**
  50163. * Define the name of the layer.
  50164. */
  50165. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50166. private _createIndexBuffer;
  50167. /** @hidden */
  50168. _rebuild(): void;
  50169. /**
  50170. * Renders the layer in the scene.
  50171. */
  50172. render(): void;
  50173. /**
  50174. * Disposes and releases the associated ressources.
  50175. */
  50176. dispose(): void;
  50177. }
  50178. }
  50179. declare module BABYLON {
  50180. /** @hidden */
  50181. export var lensFlarePixelShader: {
  50182. name: string;
  50183. shader: string;
  50184. };
  50185. }
  50186. declare module BABYLON {
  50187. /** @hidden */
  50188. export var lensFlareVertexShader: {
  50189. name: string;
  50190. shader: string;
  50191. };
  50192. }
  50193. declare module BABYLON {
  50194. /**
  50195. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50196. * It is usually composed of several `lensFlare`.
  50197. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50198. */
  50199. export class LensFlareSystem {
  50200. /**
  50201. * Define the name of the lens flare system
  50202. */
  50203. name: string;
  50204. /**
  50205. * List of lens flares used in this system.
  50206. */
  50207. lensFlares: LensFlare[];
  50208. /**
  50209. * Define a limit from the border the lens flare can be visible.
  50210. */
  50211. borderLimit: number;
  50212. /**
  50213. * Define a viewport border we do not want to see the lens flare in.
  50214. */
  50215. viewportBorder: number;
  50216. /**
  50217. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50218. */
  50219. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50220. /**
  50221. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50222. */
  50223. layerMask: number;
  50224. /**
  50225. * Define the id of the lens flare system in the scene.
  50226. * (equal to name by default)
  50227. */
  50228. id: string;
  50229. private _scene;
  50230. private _emitter;
  50231. private _vertexBuffers;
  50232. private _indexBuffer;
  50233. private _effect;
  50234. private _positionX;
  50235. private _positionY;
  50236. private _isEnabled;
  50237. /** @hidden */
  50238. static _SceneComponentInitialization: (scene: Scene) => void;
  50239. /**
  50240. * Instantiates a lens flare system.
  50241. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50242. * It is usually composed of several `lensFlare`.
  50243. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50244. * @param name Define the name of the lens flare system in the scene
  50245. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50246. * @param scene Define the scene the lens flare system belongs to
  50247. */
  50248. constructor(
  50249. /**
  50250. * Define the name of the lens flare system
  50251. */
  50252. name: string, emitter: any, scene: Scene);
  50253. /**
  50254. * Define if the lens flare system is enabled.
  50255. */
  50256. isEnabled: boolean;
  50257. /**
  50258. * Get the scene the effects belongs to.
  50259. * @returns the scene holding the lens flare system
  50260. */
  50261. getScene(): Scene;
  50262. /**
  50263. * Get the emitter of the lens flare system.
  50264. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50265. * @returns the emitter of the lens flare system
  50266. */
  50267. getEmitter(): any;
  50268. /**
  50269. * Set the emitter of the lens flare system.
  50270. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50271. * @param newEmitter Define the new emitter of the system
  50272. */
  50273. setEmitter(newEmitter: any): void;
  50274. /**
  50275. * Get the lens flare system emitter position.
  50276. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50277. * @returns the position
  50278. */
  50279. getEmitterPosition(): Vector3;
  50280. /**
  50281. * @hidden
  50282. */
  50283. computeEffectivePosition(globalViewport: Viewport): boolean;
  50284. /** @hidden */
  50285. _isVisible(): boolean;
  50286. /**
  50287. * @hidden
  50288. */
  50289. render(): boolean;
  50290. /**
  50291. * Dispose and release the lens flare with its associated resources.
  50292. */
  50293. dispose(): void;
  50294. /**
  50295. * Parse a lens flare system from a JSON repressentation
  50296. * @param parsedLensFlareSystem Define the JSON to parse
  50297. * @param scene Define the scene the parsed system should be instantiated in
  50298. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50299. * @returns the parsed system
  50300. */
  50301. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50302. /**
  50303. * Serialize the current Lens Flare System into a JSON representation.
  50304. * @returns the serialized JSON
  50305. */
  50306. serialize(): any;
  50307. }
  50308. }
  50309. declare module BABYLON {
  50310. /**
  50311. * This represents one of the lens effect in a `lensFlareSystem`.
  50312. * It controls one of the indiviual texture used in the effect.
  50313. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50314. */
  50315. export class LensFlare {
  50316. /**
  50317. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50318. */
  50319. size: number;
  50320. /**
  50321. * 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.
  50322. */
  50323. position: number;
  50324. /**
  50325. * Define the lens color.
  50326. */
  50327. color: Color3;
  50328. /**
  50329. * Define the lens texture.
  50330. */
  50331. texture: Nullable<Texture>;
  50332. /**
  50333. * Define the alpha mode to render this particular lens.
  50334. */
  50335. alphaMode: number;
  50336. private _system;
  50337. /**
  50338. * Creates a new Lens Flare.
  50339. * This represents one of the lens effect in a `lensFlareSystem`.
  50340. * It controls one of the indiviual texture used in the effect.
  50341. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50342. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50343. * @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.
  50344. * @param color Define the lens color
  50345. * @param imgUrl Define the lens texture url
  50346. * @param system Define the `lensFlareSystem` this flare is part of
  50347. * @returns The newly created Lens Flare
  50348. */
  50349. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50350. /**
  50351. * Instantiates a new Lens Flare.
  50352. * This represents one of the lens effect in a `lensFlareSystem`.
  50353. * It controls one of the indiviual texture used in the effect.
  50354. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50355. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50356. * @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.
  50357. * @param color Define the lens color
  50358. * @param imgUrl Define the lens texture url
  50359. * @param system Define the `lensFlareSystem` this flare is part of
  50360. */
  50361. constructor(
  50362. /**
  50363. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50364. */
  50365. size: number,
  50366. /**
  50367. * 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.
  50368. */
  50369. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50370. /**
  50371. * Dispose and release the lens flare with its associated resources.
  50372. */
  50373. dispose(): void;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. interface AbstractScene {
  50378. /**
  50379. * The list of lens flare system added to the scene
  50380. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50381. */
  50382. lensFlareSystems: Array<LensFlareSystem>;
  50383. /**
  50384. * Removes the given lens flare system from this scene.
  50385. * @param toRemove The lens flare system to remove
  50386. * @returns The index of the removed lens flare system
  50387. */
  50388. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50389. /**
  50390. * Adds the given lens flare system to this scene
  50391. * @param newLensFlareSystem The lens flare system to add
  50392. */
  50393. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50394. /**
  50395. * Gets a lens flare system using its name
  50396. * @param name defines the name to look for
  50397. * @returns the lens flare system or null if not found
  50398. */
  50399. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50400. /**
  50401. * Gets a lens flare system using its id
  50402. * @param id defines the id to look for
  50403. * @returns the lens flare system or null if not found
  50404. */
  50405. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50406. }
  50407. /**
  50408. * Defines the lens flare scene component responsible to manage any lens flares
  50409. * in a given scene.
  50410. */
  50411. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50412. /**
  50413. * The component name helpfull to identify the component in the list of scene components.
  50414. */
  50415. readonly name: string;
  50416. /**
  50417. * The scene the component belongs to.
  50418. */
  50419. scene: Scene;
  50420. /**
  50421. * Creates a new instance of the component for the given scene
  50422. * @param scene Defines the scene to register the component in
  50423. */
  50424. constructor(scene: Scene);
  50425. /**
  50426. * Registers the component in a given scene
  50427. */
  50428. register(): void;
  50429. /**
  50430. * Rebuilds the elements related to this component in case of
  50431. * context lost for instance.
  50432. */
  50433. rebuild(): void;
  50434. /**
  50435. * Adds all the elements from the container to the scene
  50436. * @param container the container holding the elements
  50437. */
  50438. addFromContainer(container: AbstractScene): void;
  50439. /**
  50440. * Removes all the elements in the container from the scene
  50441. * @param container contains the elements to remove
  50442. * @param dispose if the removed element should be disposed (default: false)
  50443. */
  50444. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50445. /**
  50446. * Serializes the component data to the specified json object
  50447. * @param serializationObject The object to serialize to
  50448. */
  50449. serialize(serializationObject: any): void;
  50450. /**
  50451. * Disposes the component and the associated ressources.
  50452. */
  50453. dispose(): void;
  50454. private _draw;
  50455. }
  50456. }
  50457. declare module BABYLON {
  50458. /**
  50459. * Defines the shadow generator component responsible to manage any shadow generators
  50460. * in a given scene.
  50461. */
  50462. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50463. /**
  50464. * The component name helpfull to identify the component in the list of scene components.
  50465. */
  50466. readonly name: string;
  50467. /**
  50468. * The scene the component belongs to.
  50469. */
  50470. scene: Scene;
  50471. /**
  50472. * Creates a new instance of the component for the given scene
  50473. * @param scene Defines the scene to register the component in
  50474. */
  50475. constructor(scene: Scene);
  50476. /**
  50477. * Registers the component in a given scene
  50478. */
  50479. register(): void;
  50480. /**
  50481. * Rebuilds the elements related to this component in case of
  50482. * context lost for instance.
  50483. */
  50484. rebuild(): void;
  50485. /**
  50486. * Serializes the component data to the specified json object
  50487. * @param serializationObject The object to serialize to
  50488. */
  50489. serialize(serializationObject: any): void;
  50490. /**
  50491. * Adds all the elements from the container to the scene
  50492. * @param container the container holding the elements
  50493. */
  50494. addFromContainer(container: AbstractScene): void;
  50495. /**
  50496. * Removes all the elements in the container from the scene
  50497. * @param container contains the elements to remove
  50498. * @param dispose if the removed element should be disposed (default: false)
  50499. */
  50500. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50501. /**
  50502. * Rebuilds the elements related to this component in case of
  50503. * context lost for instance.
  50504. */
  50505. dispose(): void;
  50506. private _gatherRenderTargets;
  50507. }
  50508. }
  50509. declare module BABYLON {
  50510. /**
  50511. * A point light is a light defined by an unique point in world space.
  50512. * The light is emitted in every direction from this point.
  50513. * A good example of a point light is a standard light bulb.
  50514. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50515. */
  50516. export class PointLight extends ShadowLight {
  50517. private _shadowAngle;
  50518. /**
  50519. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50520. * This specifies what angle the shadow will use to be created.
  50521. *
  50522. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50523. */
  50524. /**
  50525. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50526. * This specifies what angle the shadow will use to be created.
  50527. *
  50528. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50529. */
  50530. shadowAngle: number;
  50531. /**
  50532. * Gets the direction if it has been set.
  50533. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50534. */
  50535. /**
  50536. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50537. */
  50538. direction: Vector3;
  50539. /**
  50540. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50541. * A PointLight emits the light in every direction.
  50542. * It can cast shadows.
  50543. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50544. * ```javascript
  50545. * var pointLight = new PointLight("pl", camera.position, scene);
  50546. * ```
  50547. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50548. * @param name The light friendly name
  50549. * @param position The position of the point light in the scene
  50550. * @param scene The scene the lights belongs to
  50551. */
  50552. constructor(name: string, position: Vector3, scene: Scene);
  50553. /**
  50554. * Returns the string "PointLight"
  50555. * @returns the class name
  50556. */
  50557. getClassName(): string;
  50558. /**
  50559. * Returns the integer 0.
  50560. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50561. */
  50562. getTypeID(): number;
  50563. /**
  50564. * Specifies wether or not the shadowmap should be a cube texture.
  50565. * @returns true if the shadowmap needs to be a cube texture.
  50566. */
  50567. needCube(): boolean;
  50568. /**
  50569. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50570. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50571. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50572. */
  50573. getShadowDirection(faceIndex?: number): Vector3;
  50574. /**
  50575. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50576. * - fov = PI / 2
  50577. * - aspect ratio : 1.0
  50578. * - z-near and far equal to the active camera minZ and maxZ.
  50579. * Returns the PointLight.
  50580. */
  50581. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50582. protected _buildUniformLayout(): void;
  50583. /**
  50584. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50585. * @param effect The effect to update
  50586. * @param lightIndex The index of the light in the effect to update
  50587. * @returns The point light
  50588. */
  50589. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50590. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50591. /**
  50592. * Prepares the list of defines specific to the light type.
  50593. * @param defines the list of defines
  50594. * @param lightIndex defines the index of the light for the effect
  50595. */
  50596. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50597. }
  50598. }
  50599. declare module BABYLON {
  50600. /**
  50601. * Header information of HDR texture files.
  50602. */
  50603. export interface HDRInfo {
  50604. /**
  50605. * The height of the texture in pixels.
  50606. */
  50607. height: number;
  50608. /**
  50609. * The width of the texture in pixels.
  50610. */
  50611. width: number;
  50612. /**
  50613. * The index of the beginning of the data in the binary file.
  50614. */
  50615. dataPosition: number;
  50616. }
  50617. /**
  50618. * This groups tools to convert HDR texture to native colors array.
  50619. */
  50620. export class HDRTools {
  50621. private static Ldexp;
  50622. private static Rgbe2float;
  50623. private static readStringLine;
  50624. /**
  50625. * Reads header information from an RGBE texture stored in a native array.
  50626. * More information on this format are available here:
  50627. * https://en.wikipedia.org/wiki/RGBE_image_format
  50628. *
  50629. * @param uint8array The binary file stored in native array.
  50630. * @return The header information.
  50631. */
  50632. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50633. /**
  50634. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50635. * This RGBE texture needs to store the information as a panorama.
  50636. *
  50637. * More information on this format are available here:
  50638. * https://en.wikipedia.org/wiki/RGBE_image_format
  50639. *
  50640. * @param buffer The binary file stored in an array buffer.
  50641. * @param size The expected size of the extracted cubemap.
  50642. * @return The Cube Map information.
  50643. */
  50644. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50645. /**
  50646. * Returns the pixels data extracted from an RGBE texture.
  50647. * This pixels will be stored left to right up to down in the R G B order in one array.
  50648. *
  50649. * More information on this format are available here:
  50650. * https://en.wikipedia.org/wiki/RGBE_image_format
  50651. *
  50652. * @param uint8array The binary file stored in an array buffer.
  50653. * @param hdrInfo The header information of the file.
  50654. * @return The pixels data in RGB right to left up to down order.
  50655. */
  50656. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50657. private static RGBE_ReadPixels_RLE;
  50658. }
  50659. }
  50660. declare module BABYLON {
  50661. /**
  50662. * This represents a texture coming from an HDR input.
  50663. *
  50664. * The only supported format is currently panorama picture stored in RGBE format.
  50665. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50666. */
  50667. export class HDRCubeTexture extends BaseTexture {
  50668. private static _facesMapping;
  50669. private _generateHarmonics;
  50670. private _noMipmap;
  50671. private _textureMatrix;
  50672. private _size;
  50673. private _onLoad;
  50674. private _onError;
  50675. /**
  50676. * The texture URL.
  50677. */
  50678. url: string;
  50679. /**
  50680. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50681. */
  50682. coordinatesMode: number;
  50683. protected _isBlocking: boolean;
  50684. /**
  50685. * Sets wether or not the texture is blocking during loading.
  50686. */
  50687. /**
  50688. * Gets wether or not the texture is blocking during loading.
  50689. */
  50690. isBlocking: boolean;
  50691. protected _rotationY: number;
  50692. /**
  50693. * Sets texture matrix rotation angle around Y axis in radians.
  50694. */
  50695. /**
  50696. * Gets texture matrix rotation angle around Y axis radians.
  50697. */
  50698. rotationY: number;
  50699. /**
  50700. * Gets or sets the center of the bounding box associated with the cube texture
  50701. * It must define where the camera used to render the texture was set
  50702. */
  50703. boundingBoxPosition: Vector3;
  50704. private _boundingBoxSize;
  50705. /**
  50706. * Gets or sets the size of the bounding box associated with the cube texture
  50707. * When defined, the cubemap will switch to local mode
  50708. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50709. * @example https://www.babylonjs-playground.com/#RNASML
  50710. */
  50711. boundingBoxSize: Vector3;
  50712. /**
  50713. * Instantiates an HDRTexture from the following parameters.
  50714. *
  50715. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50716. * @param scene The scene the texture will be used in
  50717. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50718. * @param noMipmap Forces to not generate the mipmap if true
  50719. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50720. * @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)
  50721. * @param reserved Reserved flag for internal use.
  50722. */
  50723. 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>);
  50724. /**
  50725. * Get the current class name of the texture useful for serialization or dynamic coding.
  50726. * @returns "HDRCubeTexture"
  50727. */
  50728. getClassName(): string;
  50729. /**
  50730. * Occurs when the file is raw .hdr file.
  50731. */
  50732. private loadTexture;
  50733. clone(): HDRCubeTexture;
  50734. delayLoad(): void;
  50735. /**
  50736. * Get the texture reflection matrix used to rotate/transform the reflection.
  50737. * @returns the reflection matrix
  50738. */
  50739. getReflectionTextureMatrix(): Matrix;
  50740. /**
  50741. * Set the texture reflection matrix used to rotate/transform the reflection.
  50742. * @param value Define the reflection matrix to set
  50743. */
  50744. setReflectionTextureMatrix(value: Matrix): void;
  50745. /**
  50746. * Parses a JSON representation of an HDR Texture in order to create the texture
  50747. * @param parsedTexture Define the JSON representation
  50748. * @param scene Define the scene the texture should be created in
  50749. * @param rootUrl Define the root url in case we need to load relative dependencies
  50750. * @returns the newly created texture after parsing
  50751. */
  50752. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50753. serialize(): any;
  50754. }
  50755. }
  50756. declare module BABYLON {
  50757. /**
  50758. * Class used to control physics engine
  50759. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50760. */
  50761. export class PhysicsEngine implements IPhysicsEngine {
  50762. private _physicsPlugin;
  50763. /**
  50764. * Global value used to control the smallest number supported by the simulation
  50765. */
  50766. static Epsilon: number;
  50767. private _impostors;
  50768. private _joints;
  50769. /**
  50770. * Gets the gravity vector used by the simulation
  50771. */
  50772. gravity: Vector3;
  50773. /**
  50774. * Factory used to create the default physics plugin.
  50775. * @returns The default physics plugin
  50776. */
  50777. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50778. /**
  50779. * Creates a new Physics Engine
  50780. * @param gravity defines the gravity vector used by the simulation
  50781. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50782. */
  50783. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50784. /**
  50785. * Sets the gravity vector used by the simulation
  50786. * @param gravity defines the gravity vector to use
  50787. */
  50788. setGravity(gravity: Vector3): void;
  50789. /**
  50790. * Set the time step of the physics engine.
  50791. * Default is 1/60.
  50792. * To slow it down, enter 1/600 for example.
  50793. * To speed it up, 1/30
  50794. * @param newTimeStep defines the new timestep to apply to this world.
  50795. */
  50796. setTimeStep(newTimeStep?: number): void;
  50797. /**
  50798. * Get the time step of the physics engine.
  50799. * @returns the current time step
  50800. */
  50801. getTimeStep(): number;
  50802. /**
  50803. * Release all resources
  50804. */
  50805. dispose(): void;
  50806. /**
  50807. * Gets the name of the current physics plugin
  50808. * @returns the name of the plugin
  50809. */
  50810. getPhysicsPluginName(): string;
  50811. /**
  50812. * Adding a new impostor for the impostor tracking.
  50813. * This will be done by the impostor itself.
  50814. * @param impostor the impostor to add
  50815. */
  50816. addImpostor(impostor: PhysicsImpostor): void;
  50817. /**
  50818. * Remove an impostor from the engine.
  50819. * This impostor and its mesh will not longer be updated by the physics engine.
  50820. * @param impostor the impostor to remove
  50821. */
  50822. removeImpostor(impostor: PhysicsImpostor): void;
  50823. /**
  50824. * Add a joint to the physics engine
  50825. * @param mainImpostor defines the main impostor to which the joint is added.
  50826. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50827. * @param joint defines the joint that will connect both impostors.
  50828. */
  50829. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50830. /**
  50831. * Removes a joint from the simulation
  50832. * @param mainImpostor defines the impostor used with the joint
  50833. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50834. * @param joint defines the joint to remove
  50835. */
  50836. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50837. /**
  50838. * Called by the scene. No need to call it.
  50839. * @param delta defines the timespam between frames
  50840. */
  50841. _step(delta: number): void;
  50842. /**
  50843. * Gets the current plugin used to run the simulation
  50844. * @returns current plugin
  50845. */
  50846. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50847. /**
  50848. * Gets the list of physic impostors
  50849. * @returns an array of PhysicsImpostor
  50850. */
  50851. getImpostors(): Array<PhysicsImpostor>;
  50852. /**
  50853. * Gets the impostor for a physics enabled object
  50854. * @param object defines the object impersonated by the impostor
  50855. * @returns the PhysicsImpostor or null if not found
  50856. */
  50857. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50858. /**
  50859. * Gets the impostor for a physics body object
  50860. * @param body defines physics body used by the impostor
  50861. * @returns the PhysicsImpostor or null if not found
  50862. */
  50863. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50864. /**
  50865. * Does a raycast in the physics world
  50866. * @param from when should the ray start?
  50867. * @param to when should the ray end?
  50868. * @returns PhysicsRaycastResult
  50869. */
  50870. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50871. }
  50872. }
  50873. declare module BABYLON {
  50874. /** @hidden */
  50875. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50876. private _useDeltaForWorldStep;
  50877. world: any;
  50878. name: string;
  50879. private _physicsMaterials;
  50880. private _fixedTimeStep;
  50881. private _cannonRaycastResult;
  50882. private _raycastResult;
  50883. private _physicsBodysToRemoveAfterStep;
  50884. BJSCANNON: any;
  50885. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50886. setGravity(gravity: Vector3): void;
  50887. setTimeStep(timeStep: number): void;
  50888. getTimeStep(): number;
  50889. executeStep(delta: number): void;
  50890. private _removeMarkedPhysicsBodiesFromWorld;
  50891. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50892. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50893. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50894. private _processChildMeshes;
  50895. removePhysicsBody(impostor: PhysicsImpostor): void;
  50896. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50897. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50898. private _addMaterial;
  50899. private _checkWithEpsilon;
  50900. private _createShape;
  50901. private _createHeightmap;
  50902. private _minus90X;
  50903. private _plus90X;
  50904. private _tmpPosition;
  50905. private _tmpDeltaPosition;
  50906. private _tmpUnityRotation;
  50907. private _updatePhysicsBodyTransformation;
  50908. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50910. isSupported(): boolean;
  50911. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50912. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50913. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50914. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50915. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50916. getBodyMass(impostor: PhysicsImpostor): number;
  50917. getBodyFriction(impostor: PhysicsImpostor): number;
  50918. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50919. getBodyRestitution(impostor: PhysicsImpostor): number;
  50920. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50921. sleepBody(impostor: PhysicsImpostor): void;
  50922. wakeUpBody(impostor: PhysicsImpostor): void;
  50923. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50924. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50925. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50926. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50927. getRadius(impostor: PhysicsImpostor): number;
  50928. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50929. dispose(): void;
  50930. private _extendNamespace;
  50931. /**
  50932. * Does a raycast in the physics world
  50933. * @param from when should the ray start?
  50934. * @param to when should the ray end?
  50935. * @returns PhysicsRaycastResult
  50936. */
  50937. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50938. }
  50939. }
  50940. declare module BABYLON {
  50941. /** @hidden */
  50942. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50943. world: any;
  50944. name: string;
  50945. BJSOIMO: any;
  50946. private _raycastResult;
  50947. constructor(iterations?: number, oimoInjection?: any);
  50948. setGravity(gravity: Vector3): void;
  50949. setTimeStep(timeStep: number): void;
  50950. getTimeStep(): number;
  50951. private _tmpImpostorsArray;
  50952. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  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 _tmpPositionVector;
  50957. removePhysicsBody(impostor: PhysicsImpostor): void;
  50958. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50959. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50960. isSupported(): boolean;
  50961. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50962. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50963. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50964. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50965. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50966. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50967. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50968. getBodyMass(impostor: PhysicsImpostor): number;
  50969. getBodyFriction(impostor: PhysicsImpostor): number;
  50970. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50971. getBodyRestitution(impostor: PhysicsImpostor): number;
  50972. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50973. sleepBody(impostor: PhysicsImpostor): void;
  50974. wakeUpBody(impostor: PhysicsImpostor): void;
  50975. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50976. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50977. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50978. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50979. getRadius(impostor: PhysicsImpostor): number;
  50980. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50981. dispose(): void;
  50982. /**
  50983. * Does a raycast in the physics world
  50984. * @param from when should the ray start?
  50985. * @param to when should the ray end?
  50986. * @returns PhysicsRaycastResult
  50987. */
  50988. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50989. }
  50990. }
  50991. declare module BABYLON {
  50992. /**
  50993. * Class containing static functions to help procedurally build meshes
  50994. */
  50995. export class RibbonBuilder {
  50996. /**
  50997. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50998. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50999. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51000. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51001. * * 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
  51002. * * 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
  51003. * * 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
  51004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51005. * * 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
  51006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51007. * * 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
  51008. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51009. * * 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
  51010. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51012. * @param name defines the name of the mesh
  51013. * @param options defines the options used to create the mesh
  51014. * @param scene defines the hosting scene
  51015. * @returns the ribbon mesh
  51016. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51017. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51018. */
  51019. static CreateRibbon(name: string, options: {
  51020. pathArray: Vector3[][];
  51021. closeArray?: boolean;
  51022. closePath?: boolean;
  51023. offset?: number;
  51024. updatable?: boolean;
  51025. sideOrientation?: number;
  51026. frontUVs?: Vector4;
  51027. backUVs?: Vector4;
  51028. instance?: Mesh;
  51029. invertUV?: boolean;
  51030. uvs?: Vector2[];
  51031. colors?: Color4[];
  51032. }, scene?: Nullable<Scene>): Mesh;
  51033. }
  51034. }
  51035. declare module BABYLON {
  51036. /**
  51037. * Class containing static functions to help procedurally build meshes
  51038. */
  51039. export class ShapeBuilder {
  51040. /**
  51041. * 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.
  51042. * * 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.
  51043. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51044. * * 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.
  51045. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51046. * * 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
  51047. * * 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
  51048. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51050. * * 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
  51051. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51053. * @param name defines the name of the mesh
  51054. * @param options defines the options used to create the mesh
  51055. * @param scene defines the hosting scene
  51056. * @returns the extruded shape mesh
  51057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51059. */
  51060. static ExtrudeShape(name: string, options: {
  51061. shape: Vector3[];
  51062. path: Vector3[];
  51063. scale?: number;
  51064. rotation?: number;
  51065. cap?: number;
  51066. updatable?: boolean;
  51067. sideOrientation?: number;
  51068. frontUVs?: Vector4;
  51069. backUVs?: Vector4;
  51070. instance?: Mesh;
  51071. invertUV?: boolean;
  51072. }, scene?: Nullable<Scene>): Mesh;
  51073. /**
  51074. * Creates an custom extruded shape mesh.
  51075. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51076. * * 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.
  51077. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51078. * * 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
  51079. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51080. * * 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
  51081. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51082. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51083. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51084. * * 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
  51085. * * 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
  51086. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51088. * * 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
  51089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51091. * @param name defines the name of the mesh
  51092. * @param options defines the options used to create the mesh
  51093. * @param scene defines the hosting scene
  51094. * @returns the custom extruded shape mesh
  51095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51096. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51098. */
  51099. static ExtrudeShapeCustom(name: string, options: {
  51100. shape: Vector3[];
  51101. path: Vector3[];
  51102. scaleFunction?: any;
  51103. rotationFunction?: any;
  51104. ribbonCloseArray?: boolean;
  51105. ribbonClosePath?: boolean;
  51106. cap?: number;
  51107. updatable?: boolean;
  51108. sideOrientation?: number;
  51109. frontUVs?: Vector4;
  51110. backUVs?: Vector4;
  51111. instance?: Mesh;
  51112. invertUV?: boolean;
  51113. }, scene?: Nullable<Scene>): Mesh;
  51114. private static _ExtrudeShapeGeneric;
  51115. }
  51116. }
  51117. declare module BABYLON {
  51118. /**
  51119. * AmmoJS Physics plugin
  51120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51121. * @see https://github.com/kripken/ammo.js/
  51122. */
  51123. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51124. private _useDeltaForWorldStep;
  51125. /**
  51126. * Reference to the Ammo library
  51127. */
  51128. bjsAMMO: any;
  51129. /**
  51130. * Created ammoJS world which physics bodies are added to
  51131. */
  51132. world: any;
  51133. /**
  51134. * Name of the plugin
  51135. */
  51136. name: string;
  51137. private _timeStep;
  51138. private _fixedTimeStep;
  51139. private _maxSteps;
  51140. private _tmpQuaternion;
  51141. private _tmpAmmoTransform;
  51142. private _tmpAmmoQuaternion;
  51143. private _tmpAmmoConcreteContactResultCallback;
  51144. private _collisionConfiguration;
  51145. private _dispatcher;
  51146. private _overlappingPairCache;
  51147. private _solver;
  51148. private _softBodySolver;
  51149. private _tmpAmmoVectorA;
  51150. private _tmpAmmoVectorB;
  51151. private _tmpAmmoVectorC;
  51152. private _tmpAmmoVectorD;
  51153. private _tmpContactCallbackResult;
  51154. private _tmpAmmoVectorRCA;
  51155. private _tmpAmmoVectorRCB;
  51156. private _raycastResult;
  51157. private static readonly DISABLE_COLLISION_FLAG;
  51158. private static readonly KINEMATIC_FLAG;
  51159. private static readonly DISABLE_DEACTIVATION_FLAG;
  51160. /**
  51161. * Initializes the ammoJS plugin
  51162. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51163. * @param ammoInjection can be used to inject your own ammo reference
  51164. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51165. */
  51166. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51167. /**
  51168. * Sets the gravity of the physics world (m/(s^2))
  51169. * @param gravity Gravity to set
  51170. */
  51171. setGravity(gravity: Vector3): void;
  51172. /**
  51173. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51174. * @param timeStep timestep to use in seconds
  51175. */
  51176. setTimeStep(timeStep: number): void;
  51177. /**
  51178. * 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)
  51179. * @param fixedTimeStep fixedTimeStep to use in seconds
  51180. */
  51181. setFixedTimeStep(fixedTimeStep: number): void;
  51182. /**
  51183. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51184. * @param maxSteps the maximum number of steps by the physics engine per frame
  51185. */
  51186. setMaxSteps(maxSteps: number): void;
  51187. /**
  51188. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51189. * @returns the current timestep in seconds
  51190. */
  51191. getTimeStep(): number;
  51192. private _isImpostorInContact;
  51193. private _isImpostorPairInContact;
  51194. private _stepSimulation;
  51195. /**
  51196. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51197. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51198. * After the step the babylon meshes are set to the position of the physics imposters
  51199. * @param delta amount of time to step forward
  51200. * @param impostors array of imposters to update before/after the step
  51201. */
  51202. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51203. /**
  51204. * Update babylon mesh to match physics world object
  51205. * @param impostor imposter to match
  51206. */
  51207. private _afterSoftStep;
  51208. /**
  51209. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51210. * @param impostor imposter to match
  51211. */
  51212. private _ropeStep;
  51213. /**
  51214. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51215. * @param impostor imposter to match
  51216. */
  51217. private _softbodyOrClothStep;
  51218. private _tmpVector;
  51219. private _tmpMatrix;
  51220. /**
  51221. * Applies an impulse on the imposter
  51222. * @param impostor imposter to apply impulse to
  51223. * @param force amount of force to be applied to the imposter
  51224. * @param contactPoint the location to apply the impulse on the imposter
  51225. */
  51226. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51227. /**
  51228. * Applies a force on the imposter
  51229. * @param impostor imposter to apply force
  51230. * @param force amount of force to be applied to the imposter
  51231. * @param contactPoint the location to apply the force on the imposter
  51232. */
  51233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51234. /**
  51235. * Creates a physics body using the plugin
  51236. * @param impostor the imposter to create the physics body on
  51237. */
  51238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51239. /**
  51240. * Removes the physics body from the imposter and disposes of the body's memory
  51241. * @param impostor imposter to remove the physics body from
  51242. */
  51243. removePhysicsBody(impostor: PhysicsImpostor): void;
  51244. /**
  51245. * Generates a joint
  51246. * @param impostorJoint the imposter joint to create the joint with
  51247. */
  51248. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51249. /**
  51250. * Removes a joint
  51251. * @param impostorJoint the imposter joint to remove the joint from
  51252. */
  51253. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51254. private _addMeshVerts;
  51255. /**
  51256. * Initialise the soft body vertices to match its object's (mesh) vertices
  51257. * Softbody vertices (nodes) are in world space and to match this
  51258. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51259. * @param impostor to create the softbody for
  51260. */
  51261. private _softVertexData;
  51262. /**
  51263. * Create an impostor's soft body
  51264. * @param impostor to create the softbody for
  51265. */
  51266. private _createSoftbody;
  51267. /**
  51268. * Create cloth for an impostor
  51269. * @param impostor to create the softbody for
  51270. */
  51271. private _createCloth;
  51272. /**
  51273. * Create rope for an impostor
  51274. * @param impostor to create the softbody for
  51275. */
  51276. private _createRope;
  51277. private _addHullVerts;
  51278. private _createShape;
  51279. /**
  51280. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51281. * @param impostor imposter containing the physics body and babylon object
  51282. */
  51283. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51284. /**
  51285. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51286. * @param impostor imposter containing the physics body and babylon object
  51287. * @param newPosition new position
  51288. * @param newRotation new rotation
  51289. */
  51290. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51291. /**
  51292. * If this plugin is supported
  51293. * @returns true if its supported
  51294. */
  51295. isSupported(): boolean;
  51296. /**
  51297. * Sets the linear velocity of the physics body
  51298. * @param impostor imposter to set the velocity on
  51299. * @param velocity velocity to set
  51300. */
  51301. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51302. /**
  51303. * Sets the angular velocity of the physics body
  51304. * @param impostor imposter to set the velocity on
  51305. * @param velocity velocity to set
  51306. */
  51307. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51308. /**
  51309. * gets the linear velocity
  51310. * @param impostor imposter to get linear velocity from
  51311. * @returns linear velocity
  51312. */
  51313. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51314. /**
  51315. * gets the angular velocity
  51316. * @param impostor imposter to get angular velocity from
  51317. * @returns angular velocity
  51318. */
  51319. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51320. /**
  51321. * Sets the mass of physics body
  51322. * @param impostor imposter to set the mass on
  51323. * @param mass mass to set
  51324. */
  51325. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51326. /**
  51327. * Gets the mass of the physics body
  51328. * @param impostor imposter to get the mass from
  51329. * @returns mass
  51330. */
  51331. getBodyMass(impostor: PhysicsImpostor): number;
  51332. /**
  51333. * Gets friction of the impostor
  51334. * @param impostor impostor to get friction from
  51335. * @returns friction value
  51336. */
  51337. getBodyFriction(impostor: PhysicsImpostor): number;
  51338. /**
  51339. * Sets friction of the impostor
  51340. * @param impostor impostor to set friction on
  51341. * @param friction friction value
  51342. */
  51343. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51344. /**
  51345. * Gets restitution of the impostor
  51346. * @param impostor impostor to get restitution from
  51347. * @returns restitution value
  51348. */
  51349. getBodyRestitution(impostor: PhysicsImpostor): number;
  51350. /**
  51351. * Sets resitution of the impostor
  51352. * @param impostor impostor to set resitution on
  51353. * @param restitution resitution value
  51354. */
  51355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51356. /**
  51357. * Gets pressure inside the impostor
  51358. * @param impostor impostor to get pressure from
  51359. * @returns pressure value
  51360. */
  51361. getBodyPressure(impostor: PhysicsImpostor): number;
  51362. /**
  51363. * Sets pressure inside a soft body impostor
  51364. * Cloth and rope must remain 0 pressure
  51365. * @param impostor impostor to set pressure on
  51366. * @param pressure pressure value
  51367. */
  51368. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51369. /**
  51370. * Gets stiffness of the impostor
  51371. * @param impostor impostor to get stiffness from
  51372. * @returns pressure value
  51373. */
  51374. getBodyStiffness(impostor: PhysicsImpostor): number;
  51375. /**
  51376. * Sets stiffness of the impostor
  51377. * @param impostor impostor to set stiffness on
  51378. * @param stiffness stiffness value from 0 to 1
  51379. */
  51380. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51381. /**
  51382. * Gets velocityIterations of the impostor
  51383. * @param impostor impostor to get velocity iterations from
  51384. * @returns velocityIterations value
  51385. */
  51386. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51387. /**
  51388. * Sets velocityIterations of the impostor
  51389. * @param impostor impostor to set velocity iterations on
  51390. * @param velocityIterations velocityIterations value
  51391. */
  51392. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51393. /**
  51394. * Gets positionIterations of the impostor
  51395. * @param impostor impostor to get position iterations from
  51396. * @returns positionIterations value
  51397. */
  51398. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51399. /**
  51400. * Sets positionIterations of the impostor
  51401. * @param impostor impostor to set position on
  51402. * @param positionIterations positionIterations value
  51403. */
  51404. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51405. /**
  51406. * Append an anchor to a cloth object
  51407. * @param impostor is the cloth impostor to add anchor to
  51408. * @param otherImpostor is the rigid impostor to anchor to
  51409. * @param width ratio across width from 0 to 1
  51410. * @param height ratio up height from 0 to 1
  51411. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51412. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51413. */
  51414. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51415. /**
  51416. * Append an hook to a rope object
  51417. * @param impostor is the rope impostor to add hook to
  51418. * @param otherImpostor is the rigid impostor to hook to
  51419. * @param length ratio along the rope from 0 to 1
  51420. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51421. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51422. */
  51423. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51424. /**
  51425. * Sleeps the physics body and stops it from being active
  51426. * @param impostor impostor to sleep
  51427. */
  51428. sleepBody(impostor: PhysicsImpostor): void;
  51429. /**
  51430. * Activates the physics body
  51431. * @param impostor impostor to activate
  51432. */
  51433. wakeUpBody(impostor: PhysicsImpostor): void;
  51434. /**
  51435. * Updates the distance parameters of the joint
  51436. * @param joint joint to update
  51437. * @param maxDistance maximum distance of the joint
  51438. * @param minDistance minimum distance of the joint
  51439. */
  51440. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51441. /**
  51442. * Sets a motor on the joint
  51443. * @param joint joint to set motor on
  51444. * @param speed speed of the motor
  51445. * @param maxForce maximum force of the motor
  51446. * @param motorIndex index of the motor
  51447. */
  51448. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51449. /**
  51450. * Sets the motors limit
  51451. * @param joint joint to set limit on
  51452. * @param upperLimit upper limit
  51453. * @param lowerLimit lower limit
  51454. */
  51455. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51456. /**
  51457. * Syncs the position and rotation of a mesh with the impostor
  51458. * @param mesh mesh to sync
  51459. * @param impostor impostor to update the mesh with
  51460. */
  51461. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51462. /**
  51463. * Gets the radius of the impostor
  51464. * @param impostor impostor to get radius from
  51465. * @returns the radius
  51466. */
  51467. getRadius(impostor: PhysicsImpostor): number;
  51468. /**
  51469. * Gets the box size of the impostor
  51470. * @param impostor impostor to get box size from
  51471. * @param result the resulting box size
  51472. */
  51473. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51474. /**
  51475. * Disposes of the impostor
  51476. */
  51477. dispose(): void;
  51478. /**
  51479. * Does a raycast in the physics world
  51480. * @param from when should the ray start?
  51481. * @param to when should the ray end?
  51482. * @returns PhysicsRaycastResult
  51483. */
  51484. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51485. }
  51486. }
  51487. declare module BABYLON {
  51488. interface AbstractScene {
  51489. /**
  51490. * The list of reflection probes added to the scene
  51491. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51492. */
  51493. reflectionProbes: Array<ReflectionProbe>;
  51494. /**
  51495. * Removes the given reflection probe from this scene.
  51496. * @param toRemove The reflection probe to remove
  51497. * @returns The index of the removed reflection probe
  51498. */
  51499. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51500. /**
  51501. * Adds the given reflection probe to this scene.
  51502. * @param newReflectionProbe The reflection probe to add
  51503. */
  51504. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51505. }
  51506. /**
  51507. * Class used to generate realtime reflection / refraction cube textures
  51508. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51509. */
  51510. export class ReflectionProbe {
  51511. /** defines the name of the probe */
  51512. name: string;
  51513. private _scene;
  51514. private _renderTargetTexture;
  51515. private _projectionMatrix;
  51516. private _viewMatrix;
  51517. private _target;
  51518. private _add;
  51519. private _attachedMesh;
  51520. private _invertYAxis;
  51521. /** Gets or sets probe position (center of the cube map) */
  51522. position: Vector3;
  51523. /**
  51524. * Creates a new reflection probe
  51525. * @param name defines the name of the probe
  51526. * @param size defines the texture resolution (for each face)
  51527. * @param scene defines the hosting scene
  51528. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51529. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51530. */
  51531. constructor(
  51532. /** defines the name of the probe */
  51533. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51534. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51535. samples: number;
  51536. /** Gets or sets the refresh rate to use (on every frame by default) */
  51537. refreshRate: number;
  51538. /**
  51539. * Gets the hosting scene
  51540. * @returns a Scene
  51541. */
  51542. getScene(): Scene;
  51543. /** Gets the internal CubeTexture used to render to */
  51544. readonly cubeTexture: RenderTargetTexture;
  51545. /** Gets the list of meshes to render */
  51546. readonly renderList: Nullable<AbstractMesh[]>;
  51547. /**
  51548. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51549. * @param mesh defines the mesh to attach to
  51550. */
  51551. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51552. /**
  51553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51554. * @param renderingGroupId The rendering group id corresponding to its index
  51555. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51556. */
  51557. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51558. /**
  51559. * Clean all associated resources
  51560. */
  51561. dispose(): void;
  51562. /**
  51563. * Converts the reflection probe information to a readable string for debug purpose.
  51564. * @param fullDetails Supports for multiple levels of logging within scene loading
  51565. * @returns the human readable reflection probe info
  51566. */
  51567. toString(fullDetails?: boolean): string;
  51568. /**
  51569. * Get the class name of the relfection probe.
  51570. * @returns "ReflectionProbe"
  51571. */
  51572. getClassName(): string;
  51573. /**
  51574. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51575. * @returns The JSON representation of the texture
  51576. */
  51577. serialize(): any;
  51578. /**
  51579. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51580. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51581. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51582. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51583. * @returns The parsed reflection probe if successful
  51584. */
  51585. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51586. }
  51587. }
  51588. declare module BABYLON {
  51589. /** @hidden */
  51590. export var _BabylonLoaderRegistered: boolean;
  51591. }
  51592. declare module BABYLON {
  51593. /**
  51594. * The Physically based simple base material of BJS.
  51595. *
  51596. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51597. * It is used as the base class for both the specGloss and metalRough conventions.
  51598. */
  51599. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51600. /**
  51601. * Number of Simultaneous lights allowed on the material.
  51602. */
  51603. maxSimultaneousLights: number;
  51604. /**
  51605. * If sets to true, disables all the lights affecting the material.
  51606. */
  51607. disableLighting: boolean;
  51608. /**
  51609. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51610. */
  51611. environmentTexture: BaseTexture;
  51612. /**
  51613. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51614. */
  51615. invertNormalMapX: boolean;
  51616. /**
  51617. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51618. */
  51619. invertNormalMapY: boolean;
  51620. /**
  51621. * Normal map used in the model.
  51622. */
  51623. normalTexture: BaseTexture;
  51624. /**
  51625. * Emissivie color used to self-illuminate the model.
  51626. */
  51627. emissiveColor: Color3;
  51628. /**
  51629. * Emissivie texture used to self-illuminate the model.
  51630. */
  51631. emissiveTexture: BaseTexture;
  51632. /**
  51633. * Occlusion Channel Strenght.
  51634. */
  51635. occlusionStrength: number;
  51636. /**
  51637. * Occlusion Texture of the material (adding extra occlusion effects).
  51638. */
  51639. occlusionTexture: BaseTexture;
  51640. /**
  51641. * Defines the alpha limits in alpha test mode.
  51642. */
  51643. alphaCutOff: number;
  51644. /**
  51645. * Gets the current double sided mode.
  51646. */
  51647. /**
  51648. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51649. */
  51650. doubleSided: boolean;
  51651. /**
  51652. * Stores the pre-calculated light information of a mesh in a texture.
  51653. */
  51654. lightmapTexture: BaseTexture;
  51655. /**
  51656. * If true, the light map contains occlusion information instead of lighting info.
  51657. */
  51658. useLightmapAsShadowmap: boolean;
  51659. /**
  51660. * Instantiates a new PBRMaterial instance.
  51661. *
  51662. * @param name The material name
  51663. * @param scene The scene the material will be use in.
  51664. */
  51665. constructor(name: string, scene: Scene);
  51666. getClassName(): string;
  51667. }
  51668. }
  51669. declare module BABYLON {
  51670. /**
  51671. * The PBR material of BJS following the metal roughness convention.
  51672. *
  51673. * This fits to the PBR convention in the GLTF definition:
  51674. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51675. */
  51676. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51677. /**
  51678. * The base color has two different interpretations depending on the value of metalness.
  51679. * When the material is a metal, the base color is the specific measured reflectance value
  51680. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51681. * of the material.
  51682. */
  51683. baseColor: Color3;
  51684. /**
  51685. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51686. * well as opacity information in the alpha channel.
  51687. */
  51688. baseTexture: BaseTexture;
  51689. /**
  51690. * Specifies the metallic scalar value of the material.
  51691. * Can also be used to scale the metalness values of the metallic texture.
  51692. */
  51693. metallic: number;
  51694. /**
  51695. * Specifies the roughness scalar value of the material.
  51696. * Can also be used to scale the roughness values of the metallic texture.
  51697. */
  51698. roughness: number;
  51699. /**
  51700. * Texture containing both the metallic value in the B channel and the
  51701. * roughness value in the G channel to keep better precision.
  51702. */
  51703. metallicRoughnessTexture: BaseTexture;
  51704. /**
  51705. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51706. *
  51707. * @param name The material name
  51708. * @param scene The scene the material will be use in.
  51709. */
  51710. constructor(name: string, scene: Scene);
  51711. /**
  51712. * Return the currrent class name of the material.
  51713. */
  51714. getClassName(): string;
  51715. /**
  51716. * Makes a duplicate of the current material.
  51717. * @param name - name to use for the new material.
  51718. */
  51719. clone(name: string): PBRMetallicRoughnessMaterial;
  51720. /**
  51721. * Serialize the material to a parsable JSON object.
  51722. */
  51723. serialize(): any;
  51724. /**
  51725. * Parses a JSON object correponding to the serialize function.
  51726. */
  51727. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51728. }
  51729. }
  51730. declare module BABYLON {
  51731. /**
  51732. * The PBR material of BJS following the specular glossiness convention.
  51733. *
  51734. * This fits to the PBR convention in the GLTF definition:
  51735. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51736. */
  51737. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51738. /**
  51739. * Specifies the diffuse color of the material.
  51740. */
  51741. diffuseColor: Color3;
  51742. /**
  51743. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51744. * channel.
  51745. */
  51746. diffuseTexture: BaseTexture;
  51747. /**
  51748. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51749. */
  51750. specularColor: Color3;
  51751. /**
  51752. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51753. */
  51754. glossiness: number;
  51755. /**
  51756. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51757. */
  51758. specularGlossinessTexture: BaseTexture;
  51759. /**
  51760. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51761. *
  51762. * @param name The material name
  51763. * @param scene The scene the material will be use in.
  51764. */
  51765. constructor(name: string, scene: Scene);
  51766. /**
  51767. * Return the currrent class name of the material.
  51768. */
  51769. getClassName(): string;
  51770. /**
  51771. * Makes a duplicate of the current material.
  51772. * @param name - name to use for the new material.
  51773. */
  51774. clone(name: string): PBRSpecularGlossinessMaterial;
  51775. /**
  51776. * Serialize the material to a parsable JSON object.
  51777. */
  51778. serialize(): any;
  51779. /**
  51780. * Parses a JSON object correponding to the serialize function.
  51781. */
  51782. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51783. }
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51788. * It can help converting any input color in a desired output one. This can then be used to create effects
  51789. * from sepia, black and white to sixties or futuristic rendering...
  51790. *
  51791. * The only supported format is currently 3dl.
  51792. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51793. */
  51794. export class ColorGradingTexture extends BaseTexture {
  51795. /**
  51796. * The current texture matrix. (will always be identity in color grading texture)
  51797. */
  51798. private _textureMatrix;
  51799. /**
  51800. * The texture URL.
  51801. */
  51802. url: string;
  51803. /**
  51804. * Empty line regex stored for GC.
  51805. */
  51806. private static _noneEmptyLineRegex;
  51807. private _engine;
  51808. /**
  51809. * Instantiates a ColorGradingTexture from the following parameters.
  51810. *
  51811. * @param url The location of the color gradind data (currently only supporting 3dl)
  51812. * @param scene The scene the texture will be used in
  51813. */
  51814. constructor(url: string, scene: Scene);
  51815. /**
  51816. * Returns the texture matrix used in most of the material.
  51817. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51818. */
  51819. getTextureMatrix(): Matrix;
  51820. /**
  51821. * Occurs when the file being loaded is a .3dl LUT file.
  51822. */
  51823. private load3dlTexture;
  51824. /**
  51825. * Starts the loading process of the texture.
  51826. */
  51827. private loadTexture;
  51828. /**
  51829. * Clones the color gradind texture.
  51830. */
  51831. clone(): ColorGradingTexture;
  51832. /**
  51833. * Called during delayed load for textures.
  51834. */
  51835. delayLoad(): void;
  51836. /**
  51837. * Parses a color grading texture serialized by Babylon.
  51838. * @param parsedTexture The texture information being parsedTexture
  51839. * @param scene The scene to load the texture in
  51840. * @param rootUrl The root url of the data assets to load
  51841. * @return A color gradind texture
  51842. */
  51843. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51844. /**
  51845. * Serializes the LUT texture to json format.
  51846. */
  51847. serialize(): any;
  51848. }
  51849. }
  51850. declare module BABYLON {
  51851. /**
  51852. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51853. */
  51854. export class EquiRectangularCubeTexture extends BaseTexture {
  51855. /** The six faces of the cube. */
  51856. private static _FacesMapping;
  51857. private _noMipmap;
  51858. private _onLoad;
  51859. private _onError;
  51860. /** The size of the cubemap. */
  51861. private _size;
  51862. /** The buffer of the image. */
  51863. private _buffer;
  51864. /** The width of the input image. */
  51865. private _width;
  51866. /** The height of the input image. */
  51867. private _height;
  51868. /** The URL to the image. */
  51869. url: string;
  51870. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51871. coordinatesMode: number;
  51872. /**
  51873. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51874. * @param url The location of the image
  51875. * @param scene The scene the texture will be used in
  51876. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51877. * @param noMipmap Forces to not generate the mipmap if true
  51878. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51879. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51880. * @param onLoad — defines a callback called when texture is loaded
  51881. * @param onError — defines a callback called if there is an error
  51882. */
  51883. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51884. /**
  51885. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51886. */
  51887. private loadImage;
  51888. /**
  51889. * Convert the image buffer into a cubemap and create a CubeTexture.
  51890. */
  51891. private loadTexture;
  51892. /**
  51893. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51894. * @param buffer The ArrayBuffer that should be converted.
  51895. * @returns The buffer as Float32Array.
  51896. */
  51897. private getFloat32ArrayFromArrayBuffer;
  51898. /**
  51899. * Get the current class name of the texture useful for serialization or dynamic coding.
  51900. * @returns "EquiRectangularCubeTexture"
  51901. */
  51902. getClassName(): string;
  51903. /**
  51904. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51905. * @returns A clone of the current EquiRectangularCubeTexture.
  51906. */
  51907. clone(): EquiRectangularCubeTexture;
  51908. }
  51909. }
  51910. declare module BABYLON {
  51911. /**
  51912. * Based on jsTGALoader - Javascript loader for TGA file
  51913. * By Vincent Thibault
  51914. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51915. */
  51916. export class TGATools {
  51917. private static _TYPE_INDEXED;
  51918. private static _TYPE_RGB;
  51919. private static _TYPE_GREY;
  51920. private static _TYPE_RLE_INDEXED;
  51921. private static _TYPE_RLE_RGB;
  51922. private static _TYPE_RLE_GREY;
  51923. private static _ORIGIN_MASK;
  51924. private static _ORIGIN_SHIFT;
  51925. private static _ORIGIN_BL;
  51926. private static _ORIGIN_BR;
  51927. private static _ORIGIN_UL;
  51928. private static _ORIGIN_UR;
  51929. /**
  51930. * Gets the header of a TGA file
  51931. * @param data defines the TGA data
  51932. * @returns the header
  51933. */
  51934. static GetTGAHeader(data: Uint8Array): any;
  51935. /**
  51936. * Uploads TGA content to a Babylon Texture
  51937. * @hidden
  51938. */
  51939. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51940. /** @hidden */
  51941. 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;
  51942. /** @hidden */
  51943. 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;
  51944. /** @hidden */
  51945. 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;
  51946. /** @hidden */
  51947. 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;
  51948. /** @hidden */
  51949. 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;
  51950. /** @hidden */
  51951. 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;
  51952. }
  51953. }
  51954. declare module BABYLON {
  51955. /**
  51956. * Implementation of the TGA Texture Loader.
  51957. * @hidden
  51958. */
  51959. export class _TGATextureLoader implements IInternalTextureLoader {
  51960. /**
  51961. * Defines wether the loader supports cascade loading the different faces.
  51962. */
  51963. readonly supportCascades: boolean;
  51964. /**
  51965. * This returns if the loader support the current file information.
  51966. * @param extension defines the file extension of the file being loaded
  51967. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51968. * @param fallback defines the fallback internal texture if any
  51969. * @param isBase64 defines whether the texture is encoded as a base64
  51970. * @param isBuffer defines whether the texture data are stored as a buffer
  51971. * @returns true if the loader can load the specified file
  51972. */
  51973. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51974. /**
  51975. * Transform the url before loading if required.
  51976. * @param rootUrl the url of the texture
  51977. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51978. * @returns the transformed texture
  51979. */
  51980. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51981. /**
  51982. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51983. * @param rootUrl the url of the texture
  51984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51985. * @returns the fallback texture
  51986. */
  51987. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51988. /**
  51989. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51990. * @param data contains the texture data
  51991. * @param texture defines the BabylonJS internal texture
  51992. * @param createPolynomials will be true if polynomials have been requested
  51993. * @param onLoad defines the callback to trigger once the texture is ready
  51994. * @param onError defines the callback to trigger in case of error
  51995. */
  51996. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51997. /**
  51998. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51999. * @param data contains the texture data
  52000. * @param texture defines the BabylonJS internal texture
  52001. * @param callback defines the method to call once ready to upload
  52002. */
  52003. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /**
  52008. * Info about the .basis files
  52009. */
  52010. class BasisFileInfo {
  52011. /**
  52012. * If the file has alpha
  52013. */
  52014. hasAlpha: boolean;
  52015. /**
  52016. * Info about each image of the basis file
  52017. */
  52018. images: Array<{
  52019. levels: Array<{
  52020. width: number;
  52021. height: number;
  52022. transcodedPixels: ArrayBufferView;
  52023. }>;
  52024. }>;
  52025. }
  52026. /**
  52027. * Result of transcoding a basis file
  52028. */
  52029. class TranscodeResult {
  52030. /**
  52031. * Info about the .basis file
  52032. */
  52033. fileInfo: BasisFileInfo;
  52034. /**
  52035. * Format to use when loading the file
  52036. */
  52037. format: number;
  52038. }
  52039. /**
  52040. * Configuration options for the Basis transcoder
  52041. */
  52042. export class BasisTranscodeConfiguration {
  52043. /**
  52044. * Supported compression formats used to determine the supported output format of the transcoder
  52045. */
  52046. supportedCompressionFormats?: {
  52047. /**
  52048. * etc1 compression format
  52049. */
  52050. etc1?: boolean;
  52051. /**
  52052. * s3tc compression format
  52053. */
  52054. s3tc?: boolean;
  52055. /**
  52056. * pvrtc compression format
  52057. */
  52058. pvrtc?: boolean;
  52059. /**
  52060. * etc2 compression format
  52061. */
  52062. etc2?: boolean;
  52063. };
  52064. /**
  52065. * If mipmap levels should be loaded for transcoded images (Default: true)
  52066. */
  52067. loadMipmapLevels?: boolean;
  52068. /**
  52069. * Index of a single image to load (Default: all images)
  52070. */
  52071. loadSingleImage?: number;
  52072. }
  52073. /**
  52074. * Used to load .Basis files
  52075. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52076. */
  52077. export class BasisTools {
  52078. private static _IgnoreSupportedFormats;
  52079. /**
  52080. * URL to use when loading the basis transcoder
  52081. */
  52082. static JSModuleURL: string;
  52083. /**
  52084. * URL to use when loading the wasm module for the transcoder
  52085. */
  52086. static WasmModuleURL: string;
  52087. /**
  52088. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52089. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52090. * @returns internal format corresponding to the Basis format
  52091. */
  52092. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52093. private static _WorkerPromise;
  52094. private static _Worker;
  52095. private static _actionId;
  52096. private static _CreateWorkerAsync;
  52097. /**
  52098. * Transcodes a loaded image file to compressed pixel data
  52099. * @param imageData image data to transcode
  52100. * @param config configuration options for the transcoding
  52101. * @returns a promise resulting in the transcoded image
  52102. */
  52103. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52104. /**
  52105. * Loads a texture from the transcode result
  52106. * @param texture texture load to
  52107. * @param transcodeResult the result of transcoding the basis file to load from
  52108. */
  52109. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52110. }
  52111. }
  52112. declare module BABYLON {
  52113. /**
  52114. * Loader for .basis file format
  52115. */
  52116. export class _BasisTextureLoader implements IInternalTextureLoader {
  52117. /**
  52118. * Defines whether the loader supports cascade loading the different faces.
  52119. */
  52120. readonly supportCascades: boolean;
  52121. /**
  52122. * This returns if the loader support the current file information.
  52123. * @param extension defines the file extension of the file being loaded
  52124. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52125. * @param fallback defines the fallback internal texture if any
  52126. * @param isBase64 defines whether the texture is encoded as a base64
  52127. * @param isBuffer defines whether the texture data are stored as a buffer
  52128. * @returns true if the loader can load the specified file
  52129. */
  52130. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52131. /**
  52132. * Transform the url before loading if required.
  52133. * @param rootUrl the url of the texture
  52134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52135. * @returns the transformed texture
  52136. */
  52137. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52138. /**
  52139. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52140. * @param rootUrl the url of the texture
  52141. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52142. * @returns the fallback texture
  52143. */
  52144. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52145. /**
  52146. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52147. * @param data contains the texture data
  52148. * @param texture defines the BabylonJS internal texture
  52149. * @param createPolynomials will be true if polynomials have been requested
  52150. * @param onLoad defines the callback to trigger once the texture is ready
  52151. * @param onError defines the callback to trigger in case of error
  52152. */
  52153. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52154. /**
  52155. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52156. * @param data contains the texture data
  52157. * @param texture defines the BabylonJS internal texture
  52158. * @param callback defines the method to call once ready to upload
  52159. */
  52160. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. /**
  52165. * 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.
  52166. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52167. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52168. */
  52169. export class CustomProceduralTexture extends ProceduralTexture {
  52170. private _animate;
  52171. private _time;
  52172. private _config;
  52173. private _texturePath;
  52174. /**
  52175. * Instantiates a new Custom Procedural Texture.
  52176. * 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.
  52177. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52178. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52179. * @param name Define the name of the texture
  52180. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52181. * @param size Define the size of the texture to create
  52182. * @param scene Define the scene the texture belongs to
  52183. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52184. * @param generateMipMaps Define if the texture should creates mip maps or not
  52185. */
  52186. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52187. private _loadJson;
  52188. /**
  52189. * Is the texture ready to be used ? (rendered at least once)
  52190. * @returns true if ready, otherwise, false.
  52191. */
  52192. isReady(): boolean;
  52193. /**
  52194. * Render the texture to its associated render target.
  52195. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52196. */
  52197. render(useCameraPostProcess?: boolean): void;
  52198. /**
  52199. * Update the list of dependant textures samplers in the shader.
  52200. */
  52201. updateTextures(): void;
  52202. /**
  52203. * Update the uniform values of the procedural texture in the shader.
  52204. */
  52205. updateShaderUniforms(): void;
  52206. /**
  52207. * Define if the texture animates or not.
  52208. */
  52209. animate: boolean;
  52210. }
  52211. }
  52212. declare module BABYLON {
  52213. /** @hidden */
  52214. export var noisePixelShader: {
  52215. name: string;
  52216. shader: string;
  52217. };
  52218. }
  52219. declare module BABYLON {
  52220. /**
  52221. * Class used to generate noise procedural textures
  52222. */
  52223. export class NoiseProceduralTexture extends ProceduralTexture {
  52224. private _time;
  52225. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52226. brightness: number;
  52227. /** Defines the number of octaves to process */
  52228. octaves: number;
  52229. /** Defines the level of persistence (0.8 by default) */
  52230. persistence: number;
  52231. /** Gets or sets animation speed factor (default is 1) */
  52232. animationSpeedFactor: number;
  52233. /**
  52234. * Creates a new NoiseProceduralTexture
  52235. * @param name defines the name fo the texture
  52236. * @param size defines the size of the texture (default is 256)
  52237. * @param scene defines the hosting scene
  52238. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52239. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52240. */
  52241. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52242. private _updateShaderUniforms;
  52243. protected _getDefines(): string;
  52244. /** Generate the current state of the procedural texture */
  52245. render(useCameraPostProcess?: boolean): void;
  52246. /**
  52247. * Serializes this noise procedural texture
  52248. * @returns a serialized noise procedural texture object
  52249. */
  52250. serialize(): any;
  52251. /**
  52252. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52253. * @param parsedTexture defines parsed texture data
  52254. * @param scene defines the current scene
  52255. * @param rootUrl defines the root URL containing noise procedural texture information
  52256. * @returns a parsed NoiseProceduralTexture
  52257. */
  52258. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52259. }
  52260. }
  52261. declare module BABYLON {
  52262. /**
  52263. * Raw cube texture where the raw buffers are passed in
  52264. */
  52265. export class RawCubeTexture extends CubeTexture {
  52266. /**
  52267. * Creates a cube texture where the raw buffers are passed in.
  52268. * @param scene defines the scene the texture is attached to
  52269. * @param data defines the array of data to use to create each face
  52270. * @param size defines the size of the textures
  52271. * @param format defines the format of the data
  52272. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52273. * @param generateMipMaps defines if the engine should generate the mip levels
  52274. * @param invertY defines if data must be stored with Y axis inverted
  52275. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52276. * @param compression defines the compression used (null by default)
  52277. */
  52278. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52279. /**
  52280. * Updates the raw cube texture.
  52281. * @param data defines the data to store
  52282. * @param format defines the data format
  52283. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52284. * @param invertY defines if data must be stored with Y axis inverted
  52285. * @param compression defines the compression used (null by default)
  52286. * @param level defines which level of the texture to update
  52287. */
  52288. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52289. /**
  52290. * Updates a raw cube texture with RGBD encoded data.
  52291. * @param data defines the array of data [mipmap][face] to use to create each face
  52292. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52293. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52294. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52295. * @returns a promsie that resolves when the operation is complete
  52296. */
  52297. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52298. /**
  52299. * Clones the raw cube texture.
  52300. * @return a new cube texture
  52301. */
  52302. clone(): CubeTexture;
  52303. /** @hidden */
  52304. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52305. }
  52306. }
  52307. declare module BABYLON {
  52308. /**
  52309. * Class used to store 3D textures containing user data
  52310. */
  52311. export class RawTexture3D extends Texture {
  52312. /** Gets or sets the texture format to use */
  52313. format: number;
  52314. private _engine;
  52315. /**
  52316. * Create a new RawTexture3D
  52317. * @param data defines the data of the texture
  52318. * @param width defines the width of the texture
  52319. * @param height defines the height of the texture
  52320. * @param depth defines the depth of the texture
  52321. * @param format defines the texture format to use
  52322. * @param scene defines the hosting scene
  52323. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52324. * @param invertY defines if texture must be stored with Y axis inverted
  52325. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52326. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52327. */
  52328. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52329. /** Gets or sets the texture format to use */
  52330. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52331. /**
  52332. * Update the texture with new data
  52333. * @param data defines the data to store in the texture
  52334. */
  52335. update(data: ArrayBufferView): void;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Creates a refraction texture used by refraction channel of the standard material.
  52341. * It is like a mirror but to see through a material.
  52342. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52343. */
  52344. export class RefractionTexture extends RenderTargetTexture {
  52345. /**
  52346. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52347. * 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.
  52348. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52349. */
  52350. refractionPlane: Plane;
  52351. /**
  52352. * Define how deep under the surface we should see.
  52353. */
  52354. depth: number;
  52355. /**
  52356. * Creates a refraction texture used by refraction channel of the standard material.
  52357. * It is like a mirror but to see through a material.
  52358. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52359. * @param name Define the texture name
  52360. * @param size Define the size of the underlying texture
  52361. * @param scene Define the scene the refraction belongs to
  52362. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52363. */
  52364. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52365. /**
  52366. * Clone the refraction texture.
  52367. * @returns the cloned texture
  52368. */
  52369. clone(): RefractionTexture;
  52370. /**
  52371. * Serialize the texture to a JSON representation you could use in Parse later on
  52372. * @returns the serialized JSON representation
  52373. */
  52374. serialize(): any;
  52375. }
  52376. }
  52377. declare module BABYLON {
  52378. /**
  52379. * Defines the options related to the creation of an HtmlElementTexture
  52380. */
  52381. export interface IHtmlElementTextureOptions {
  52382. /**
  52383. * Defines wether mip maps should be created or not.
  52384. */
  52385. generateMipMaps?: boolean;
  52386. /**
  52387. * Defines the sampling mode of the texture.
  52388. */
  52389. samplingMode?: number;
  52390. /**
  52391. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52392. */
  52393. engine: Nullable<Engine>;
  52394. /**
  52395. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52396. */
  52397. scene: Nullable<Scene>;
  52398. }
  52399. /**
  52400. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52401. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52402. * is automatically managed.
  52403. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52404. * in your application.
  52405. *
  52406. * As the update is not automatic, you need to call them manually.
  52407. */
  52408. export class HtmlElementTexture extends BaseTexture {
  52409. /**
  52410. * The texture URL.
  52411. */
  52412. element: HTMLVideoElement | HTMLCanvasElement;
  52413. private static readonly DefaultOptions;
  52414. private _textureMatrix;
  52415. private _engine;
  52416. private _isVideo;
  52417. private _generateMipMaps;
  52418. private _samplingMode;
  52419. /**
  52420. * Instantiates a HtmlElementTexture from the following parameters.
  52421. *
  52422. * @param name Defines the name of the texture
  52423. * @param element Defines the video or canvas the texture is filled with
  52424. * @param options Defines the other none mandatory texture creation options
  52425. */
  52426. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52427. private _createInternalTexture;
  52428. /**
  52429. * Returns the texture matrix used in most of the material.
  52430. */
  52431. getTextureMatrix(): Matrix;
  52432. /**
  52433. * Updates the content of the texture.
  52434. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52435. */
  52436. update(invertY?: Nullable<boolean>): void;
  52437. }
  52438. }
  52439. declare module BABYLON {
  52440. /**
  52441. * Enum used to define the target of a block
  52442. */
  52443. export enum NodeMaterialBlockTargets {
  52444. /** Vertex shader */
  52445. Vertex = 1,
  52446. /** Fragment shader */
  52447. Fragment = 2,
  52448. /** Neutral */
  52449. Neutral = 4,
  52450. /** Vertex and Fragment */
  52451. VertexAndFragment = 3
  52452. }
  52453. }
  52454. declare module BABYLON {
  52455. /**
  52456. * Defines the kind of connection point for node based material
  52457. */
  52458. export enum NodeMaterialBlockConnectionPointTypes {
  52459. /** Float */
  52460. Float = 1,
  52461. /** Int */
  52462. Int = 2,
  52463. /** Vector2 */
  52464. Vector2 = 4,
  52465. /** Vector3 */
  52466. Vector3 = 8,
  52467. /** Vector4 */
  52468. Vector4 = 16,
  52469. /** Color3 */
  52470. Color3 = 32,
  52471. /** Color4 */
  52472. Color4 = 64,
  52473. /** Matrix */
  52474. Matrix = 128,
  52475. /** Detect type based on connection */
  52476. AutoDetect = 1024,
  52477. /** Output type that will be defined by input type */
  52478. BasedOnInput = 2048
  52479. }
  52480. }
  52481. declare module BABYLON {
  52482. /**
  52483. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52484. */
  52485. export enum NodeMaterialBlockConnectionPointMode {
  52486. /** Value is an uniform */
  52487. Uniform = 0,
  52488. /** Value is a mesh attribute */
  52489. Attribute = 1,
  52490. /** Value is a varying between vertex and fragment shaders */
  52491. Varying = 2,
  52492. /** Mode is undefined */
  52493. Undefined = 3
  52494. }
  52495. }
  52496. declare module BABYLON {
  52497. /**
  52498. * Enum used to define system values e.g. values automatically provided by the system
  52499. */
  52500. export enum NodeMaterialSystemValues {
  52501. /** World */
  52502. World = 1,
  52503. /** View */
  52504. View = 2,
  52505. /** Projection */
  52506. Projection = 3,
  52507. /** ViewProjection */
  52508. ViewProjection = 4,
  52509. /** WorldView */
  52510. WorldView = 5,
  52511. /** WorldViewProjection */
  52512. WorldViewProjection = 6,
  52513. /** CameraPosition */
  52514. CameraPosition = 7,
  52515. /** Fog Color */
  52516. FogColor = 8
  52517. }
  52518. }
  52519. declare module BABYLON {
  52520. /**
  52521. * Root class for all node material optimizers
  52522. */
  52523. export class NodeMaterialOptimizer {
  52524. /**
  52525. * Function used to optimize a NodeMaterial graph
  52526. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52527. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52528. */
  52529. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52530. }
  52531. }
  52532. declare module BABYLON {
  52533. /**
  52534. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  52535. */
  52536. export class TransformBlock extends NodeMaterialBlock {
  52537. /**
  52538. * Defines the value to use to complement W value to transform it to a Vector4
  52539. */
  52540. complementW: number;
  52541. /**
  52542. * Defines the value to use to complement z value to transform it to a Vector4
  52543. */
  52544. complementZ: number;
  52545. /**
  52546. * Creates a new TransformBlock
  52547. * @param name defines the block name
  52548. */
  52549. constructor(name: string);
  52550. /**
  52551. * Gets the current class name
  52552. * @returns the class name
  52553. */
  52554. getClassName(): string;
  52555. /**
  52556. * Gets the vector input
  52557. */
  52558. readonly vector: NodeMaterialConnectionPoint;
  52559. /**
  52560. * Gets the output component
  52561. */
  52562. readonly output: NodeMaterialConnectionPoint;
  52563. /**
  52564. * Gets the matrix transform input
  52565. */
  52566. readonly transform: NodeMaterialConnectionPoint;
  52567. protected _buildBlock(state: NodeMaterialBuildState): this;
  52568. serialize(): any;
  52569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52570. protected _dumpPropertiesCode(): string;
  52571. }
  52572. }
  52573. declare module BABYLON {
  52574. /**
  52575. * Block used to output the vertex position
  52576. */
  52577. export class VertexOutputBlock extends NodeMaterialBlock {
  52578. /**
  52579. * Creates a new VertexOutputBlock
  52580. * @param name defines the block name
  52581. */
  52582. constructor(name: string);
  52583. /**
  52584. * Gets the current class name
  52585. * @returns the class name
  52586. */
  52587. getClassName(): string;
  52588. /**
  52589. * Gets the vector input component
  52590. */
  52591. readonly vector: NodeMaterialConnectionPoint;
  52592. protected _buildBlock(state: NodeMaterialBuildState): this;
  52593. }
  52594. }
  52595. declare module BABYLON {
  52596. /**
  52597. * Block used to output the final color
  52598. */
  52599. export class FragmentOutputBlock extends NodeMaterialBlock {
  52600. /**
  52601. * Create a new FragmentOutputBlock
  52602. * @param name defines the block name
  52603. */
  52604. constructor(name: string);
  52605. /**
  52606. * Gets the current class name
  52607. * @returns the class name
  52608. */
  52609. getClassName(): string;
  52610. /**
  52611. * Gets the rgba input component
  52612. */
  52613. readonly rgba: NodeMaterialConnectionPoint;
  52614. /**
  52615. * Gets the rgb input component
  52616. */
  52617. readonly rgb: NodeMaterialConnectionPoint;
  52618. /**
  52619. * Gets the a input component
  52620. */
  52621. readonly a: NodeMaterialConnectionPoint;
  52622. protected _buildBlock(state: NodeMaterialBuildState): this;
  52623. }
  52624. }
  52625. declare module BABYLON {
  52626. /**
  52627. * Block used to read a reflection texture from a sampler
  52628. */
  52629. export class ReflectionTextureBlock extends NodeMaterialBlock {
  52630. private _define3DName;
  52631. private _defineCubicName;
  52632. private _defineExplicitName;
  52633. private _defineProjectionName;
  52634. private _defineLocalCubicName;
  52635. private _defineSphericalName;
  52636. private _definePlanarName;
  52637. private _defineEquirectangularName;
  52638. private _defineMirroredEquirectangularFixedName;
  52639. private _defineEquirectangularFixedName;
  52640. private _defineSkyboxName;
  52641. private _cubeSamplerName;
  52642. private _2DSamplerName;
  52643. private _positionUVWName;
  52644. private _directionWName;
  52645. private _reflectionCoordsName;
  52646. private _reflection2DCoordsName;
  52647. private _reflectionColorName;
  52648. private _reflectionMatrixName;
  52649. /**
  52650. * Gets or sets the texture associated with the node
  52651. */
  52652. texture: Nullable<BaseTexture>;
  52653. /**
  52654. * Create a new TextureBlock
  52655. * @param name defines the block name
  52656. */
  52657. constructor(name: string);
  52658. /**
  52659. * Gets the current class name
  52660. * @returns the class name
  52661. */
  52662. getClassName(): string;
  52663. /**
  52664. * Gets the world position input component
  52665. */
  52666. readonly position: NodeMaterialConnectionPoint;
  52667. /**
  52668. * Gets the world position input component
  52669. */
  52670. readonly worldPosition: NodeMaterialConnectionPoint;
  52671. /**
  52672. * Gets the world normal input component
  52673. */
  52674. readonly worldNormal: NodeMaterialConnectionPoint;
  52675. /**
  52676. * Gets the world input component
  52677. */
  52678. readonly world: NodeMaterialConnectionPoint;
  52679. /**
  52680. * Gets the camera (or eye) position component
  52681. */
  52682. readonly cameraPosition: NodeMaterialConnectionPoint;
  52683. /**
  52684. * Gets the view input component
  52685. */
  52686. readonly view: NodeMaterialConnectionPoint;
  52687. /**
  52688. * Gets the rgb output component
  52689. */
  52690. readonly rgb: NodeMaterialConnectionPoint;
  52691. /**
  52692. * Gets the r output component
  52693. */
  52694. readonly r: NodeMaterialConnectionPoint;
  52695. /**
  52696. * Gets the g output component
  52697. */
  52698. readonly g: NodeMaterialConnectionPoint;
  52699. /**
  52700. * Gets the b output component
  52701. */
  52702. readonly b: NodeMaterialConnectionPoint;
  52703. autoConfigure(material: NodeMaterial): void;
  52704. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52705. isReady(): boolean;
  52706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52707. private _injectVertexCode;
  52708. private _writeOutput;
  52709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52710. serialize(): any;
  52711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52712. }
  52713. }
  52714. declare module BABYLON {
  52715. /**
  52716. * Interface used to configure the node material editor
  52717. */
  52718. export interface INodeMaterialEditorOptions {
  52719. /** Define the URl to load node editor script */
  52720. editorURL?: string;
  52721. }
  52722. /** @hidden */
  52723. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52724. /** BONES */
  52725. NUM_BONE_INFLUENCERS: number;
  52726. BonesPerMesh: number;
  52727. BONETEXTURE: boolean;
  52728. /** MORPH TARGETS */
  52729. MORPHTARGETS: boolean;
  52730. MORPHTARGETS_NORMAL: boolean;
  52731. MORPHTARGETS_TANGENT: boolean;
  52732. MORPHTARGETS_UV: boolean;
  52733. NUM_MORPH_INFLUENCERS: number;
  52734. /** IMAGE PROCESSING */
  52735. IMAGEPROCESSING: boolean;
  52736. VIGNETTE: boolean;
  52737. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52738. VIGNETTEBLENDMODEOPAQUE: boolean;
  52739. TONEMAPPING: boolean;
  52740. TONEMAPPING_ACES: boolean;
  52741. CONTRAST: boolean;
  52742. EXPOSURE: boolean;
  52743. COLORCURVES: boolean;
  52744. COLORGRADING: boolean;
  52745. COLORGRADING3D: boolean;
  52746. SAMPLER3DGREENDEPTH: boolean;
  52747. SAMPLER3DBGRMAP: boolean;
  52748. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52749. /** MISC. */
  52750. BUMPDIRECTUV: number;
  52751. constructor();
  52752. setValue(name: string, value: boolean): void;
  52753. }
  52754. /**
  52755. * Class used to configure NodeMaterial
  52756. */
  52757. export interface INodeMaterialOptions {
  52758. /**
  52759. * Defines if blocks should emit comments
  52760. */
  52761. emitComments: boolean;
  52762. }
  52763. /**
  52764. * Class used to create a node based material built by assembling shader blocks
  52765. */
  52766. export class NodeMaterial extends PushMaterial {
  52767. private static _BuildIdGenerator;
  52768. private _options;
  52769. private _vertexCompilationState;
  52770. private _fragmentCompilationState;
  52771. private _sharedData;
  52772. private _buildId;
  52773. private _buildWasSuccessful;
  52774. private _cachedWorldViewMatrix;
  52775. private _cachedWorldViewProjectionMatrix;
  52776. private _optimizers;
  52777. private _animationFrame;
  52778. /** Define the URl to load node editor script */
  52779. static EditorURL: string;
  52780. private BJSNODEMATERIALEDITOR;
  52781. /** Get the inspector from bundle or global */
  52782. private _getGlobalNodeMaterialEditor;
  52783. /**
  52784. * 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)
  52785. */
  52786. ignoreAlpha: boolean;
  52787. /**
  52788. * Defines the maximum number of lights that can be used in the material
  52789. */
  52790. maxSimultaneousLights: number;
  52791. /**
  52792. * Observable raised when the material is built
  52793. */
  52794. onBuildObservable: Observable<NodeMaterial>;
  52795. /**
  52796. * Gets or sets the root nodes of the material vertex shader
  52797. */
  52798. _vertexOutputNodes: NodeMaterialBlock[];
  52799. /**
  52800. * Gets or sets the root nodes of the material fragment (pixel) shader
  52801. */
  52802. _fragmentOutputNodes: NodeMaterialBlock[];
  52803. /** Gets or sets options to control the node material overall behavior */
  52804. options: INodeMaterialOptions;
  52805. /**
  52806. * Default configuration related to image processing available in the standard Material.
  52807. */
  52808. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52809. /**
  52810. * Gets the image processing configuration used either in this material.
  52811. */
  52812. /**
  52813. * Sets the Default image processing configuration used either in the this material.
  52814. *
  52815. * If sets to null, the scene one is in use.
  52816. */
  52817. imageProcessingConfiguration: ImageProcessingConfiguration;
  52818. /**
  52819. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52820. */
  52821. attachedBlocks: NodeMaterialBlock[];
  52822. /**
  52823. * Create a new node based material
  52824. * @param name defines the material name
  52825. * @param scene defines the hosting scene
  52826. * @param options defines creation option
  52827. */
  52828. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52829. /**
  52830. * Gets the current class name of the material e.g. "NodeMaterial"
  52831. * @returns the class name
  52832. */
  52833. getClassName(): string;
  52834. /**
  52835. * Keep track of the image processing observer to allow dispose and replace.
  52836. */
  52837. private _imageProcessingObserver;
  52838. /**
  52839. * Attaches a new image processing configuration to the Standard Material.
  52840. * @param configuration
  52841. */
  52842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52843. /**
  52844. * Get a block by its name
  52845. * @param name defines the name of the block to retrieve
  52846. * @returns the required block or null if not found
  52847. */
  52848. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52849. /**
  52850. * Get a block by its name
  52851. * @param predicate defines the predicate used to find the good candidate
  52852. * @returns the required block or null if not found
  52853. */
  52854. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52855. /**
  52856. * Get an input block by its name
  52857. * @param predicate defines the predicate used to find the good candidate
  52858. * @returns the required input block or null if not found
  52859. */
  52860. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52861. /**
  52862. * Gets the list of input blocks attached to this material
  52863. * @returns an array of InputBlocks
  52864. */
  52865. getInputBlocks(): InputBlock[];
  52866. /**
  52867. * Adds a new optimizer to the list of optimizers
  52868. * @param optimizer defines the optimizers to add
  52869. * @returns the current material
  52870. */
  52871. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52872. /**
  52873. * Remove an optimizer from the list of optimizers
  52874. * @param optimizer defines the optimizers to remove
  52875. * @returns the current material
  52876. */
  52877. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52878. /**
  52879. * Add a new block to the list of output nodes
  52880. * @param node defines the node to add
  52881. * @returns the current material
  52882. */
  52883. addOutputNode(node: NodeMaterialBlock): this;
  52884. /**
  52885. * Remove a block from the list of root nodes
  52886. * @param node defines the node to remove
  52887. * @returns the current material
  52888. */
  52889. removeOutputNode(node: NodeMaterialBlock): this;
  52890. private _addVertexOutputNode;
  52891. private _removeVertexOutputNode;
  52892. private _addFragmentOutputNode;
  52893. private _removeFragmentOutputNode;
  52894. /**
  52895. * Specifies if the material will require alpha blending
  52896. * @returns a boolean specifying if alpha blending is needed
  52897. */
  52898. needAlphaBlending(): boolean;
  52899. /**
  52900. * Specifies if this material should be rendered in alpha test mode
  52901. * @returns a boolean specifying if an alpha test is needed.
  52902. */
  52903. needAlphaTesting(): boolean;
  52904. private _initializeBlock;
  52905. private _resetDualBlocks;
  52906. /**
  52907. * Build the material and generates the inner effect
  52908. * @param verbose defines if the build should log activity
  52909. */
  52910. build(verbose?: boolean): void;
  52911. /**
  52912. * Runs an otpimization phase to try to improve the shader code
  52913. */
  52914. optimize(): void;
  52915. private _prepareDefinesForAttributes;
  52916. /**
  52917. * Get if the submesh is ready to be used and all its information available.
  52918. * Child classes can use it to update shaders
  52919. * @param mesh defines the mesh to check
  52920. * @param subMesh defines which submesh to check
  52921. * @param useInstances specifies that instances should be used
  52922. * @returns a boolean indicating that the submesh is ready or not
  52923. */
  52924. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52925. /**
  52926. * Get a string representing the shaders built by the current node graph
  52927. */
  52928. readonly compiledShaders: string;
  52929. /**
  52930. * Binds the world matrix to the material
  52931. * @param world defines the world transformation matrix
  52932. */
  52933. bindOnlyWorldMatrix(world: Matrix): void;
  52934. /**
  52935. * Binds the submesh to this material by preparing the effect and shader to draw
  52936. * @param world defines the world transformation matrix
  52937. * @param mesh defines the mesh containing the submesh
  52938. * @param subMesh defines the submesh to bind the material to
  52939. */
  52940. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52941. /**
  52942. * Gets the active textures from the material
  52943. * @returns an array of textures
  52944. */
  52945. getActiveTextures(): BaseTexture[];
  52946. /**
  52947. * Gets the list of texture blocks
  52948. * @returns an array of texture blocks
  52949. */
  52950. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52951. /**
  52952. * Specifies if the material uses a texture
  52953. * @param texture defines the texture to check against the material
  52954. * @returns a boolean specifying if the material uses the texture
  52955. */
  52956. hasTexture(texture: BaseTexture): boolean;
  52957. /**
  52958. * Disposes the material
  52959. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52960. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52961. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52962. */
  52963. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52964. /** Creates the node editor window. */
  52965. private _createNodeEditor;
  52966. /**
  52967. * Launch the node material editor
  52968. * @param config Define the configuration of the editor
  52969. * @return a promise fulfilled when the node editor is visible
  52970. */
  52971. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52972. /**
  52973. * Clear the current material
  52974. */
  52975. clear(): void;
  52976. /**
  52977. * Clear the current material and set it to a default state
  52978. */
  52979. setToDefault(): void;
  52980. /**
  52981. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52982. * @param url defines the url to load from
  52983. * @returns a promise that will fullfil when the material is fully loaded
  52984. */
  52985. loadAsync(url: string): Promise<unknown>;
  52986. private _gatherBlocks;
  52987. /**
  52988. * Generate a string containing the code declaration required to create an equivalent of this material
  52989. * @returns a string
  52990. */
  52991. generateCode(): string;
  52992. /**
  52993. * Serializes this material in a JSON representation
  52994. * @returns the serialized material object
  52995. */
  52996. serialize(): any;
  52997. private _restoreConnections;
  52998. /**
  52999. * Clear the current graph and load a new one from a serialization object
  53000. * @param source defines the JSON representation of the material
  53001. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53002. */
  53003. loadFromSerialization(source: any, rootUrl?: string): void;
  53004. /**
  53005. * Creates a node material from parsed material data
  53006. * @param source defines the JSON representation of the material
  53007. * @param scene defines the hosting scene
  53008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53009. * @returns a new node material
  53010. */
  53011. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53012. /**
  53013. * Creates a new node material set to default basic configuration
  53014. * @param name defines the name of the material
  53015. * @param scene defines the hosting scene
  53016. * @returns a new NodeMaterial
  53017. */
  53018. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  53019. }
  53020. }
  53021. declare module BABYLON {
  53022. /**
  53023. * Block used to read a texture from a sampler
  53024. */
  53025. export class TextureBlock extends NodeMaterialBlock {
  53026. private _defineName;
  53027. private _samplerName;
  53028. private _transformedUVName;
  53029. private _textureTransformName;
  53030. private _textureInfoName;
  53031. private _mainUVName;
  53032. private _mainUVDefineName;
  53033. /**
  53034. * Gets or sets the texture associated with the node
  53035. */
  53036. texture: Nullable<Texture>;
  53037. /**
  53038. * Create a new TextureBlock
  53039. * @param name defines the block name
  53040. */
  53041. constructor(name: string);
  53042. /**
  53043. * Gets the current class name
  53044. * @returns the class name
  53045. */
  53046. getClassName(): string;
  53047. /**
  53048. * Gets the uv input component
  53049. */
  53050. readonly uv: NodeMaterialConnectionPoint;
  53051. /**
  53052. * Gets the rgba output component
  53053. */
  53054. readonly rgba: NodeMaterialConnectionPoint;
  53055. /**
  53056. * Gets the rgb output component
  53057. */
  53058. readonly rgb: NodeMaterialConnectionPoint;
  53059. /**
  53060. * Gets the r output component
  53061. */
  53062. readonly r: NodeMaterialConnectionPoint;
  53063. /**
  53064. * Gets the g output component
  53065. */
  53066. readonly g: NodeMaterialConnectionPoint;
  53067. /**
  53068. * Gets the b output component
  53069. */
  53070. readonly b: NodeMaterialConnectionPoint;
  53071. /**
  53072. * Gets the a output component
  53073. */
  53074. readonly a: NodeMaterialConnectionPoint;
  53075. readonly target: NodeMaterialBlockTargets;
  53076. autoConfigure(material: NodeMaterial): void;
  53077. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53079. isReady(): boolean;
  53080. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53081. private readonly _isMixed;
  53082. private _injectVertexCode;
  53083. private _writeOutput;
  53084. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53085. protected _dumpPropertiesCode(): string;
  53086. serialize(): any;
  53087. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53088. }
  53089. }
  53090. declare module BABYLON {
  53091. /**
  53092. * Class used to store shared data between 2 NodeMaterialBuildState
  53093. */
  53094. export class NodeMaterialBuildStateSharedData {
  53095. /**
  53096. * Gets the list of emitted varyings
  53097. */
  53098. temps: string[];
  53099. /**
  53100. * Gets the list of emitted varyings
  53101. */
  53102. varyings: string[];
  53103. /**
  53104. * Gets the varying declaration string
  53105. */
  53106. varyingDeclaration: string;
  53107. /**
  53108. * Input blocks
  53109. */
  53110. inputBlocks: InputBlock[];
  53111. /**
  53112. * Input blocks
  53113. */
  53114. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  53115. /**
  53116. * Bindable blocks (Blocks that need to set data to the effect)
  53117. */
  53118. bindableBlocks: NodeMaterialBlock[];
  53119. /**
  53120. * List of blocks that can provide a compilation fallback
  53121. */
  53122. blocksWithFallbacks: NodeMaterialBlock[];
  53123. /**
  53124. * List of blocks that can provide a define update
  53125. */
  53126. blocksWithDefines: NodeMaterialBlock[];
  53127. /**
  53128. * List of blocks that can provide a repeatable content
  53129. */
  53130. repeatableContentBlocks: NodeMaterialBlock[];
  53131. /**
  53132. * List of blocks that can provide a dynamic list of uniforms
  53133. */
  53134. dynamicUniformBlocks: NodeMaterialBlock[];
  53135. /**
  53136. * List of blocks that can block the isReady function for the material
  53137. */
  53138. blockingBlocks: NodeMaterialBlock[];
  53139. /**
  53140. * Gets the list of animated inputs
  53141. */
  53142. animatedInputs: InputBlock[];
  53143. /**
  53144. * Build Id used to avoid multiple recompilations
  53145. */
  53146. buildId: number;
  53147. /** List of emitted variables */
  53148. variableNames: {
  53149. [key: string]: number;
  53150. };
  53151. /** List of emitted defines */
  53152. defineNames: {
  53153. [key: string]: number;
  53154. };
  53155. /** Should emit comments? */
  53156. emitComments: boolean;
  53157. /** Emit build activity */
  53158. verbose: boolean;
  53159. /** Gets or sets the hosting scene */
  53160. scene: Scene;
  53161. /**
  53162. * Gets the compilation hints emitted at compilation time
  53163. */
  53164. hints: {
  53165. needWorldViewMatrix: boolean;
  53166. needWorldViewProjectionMatrix: boolean;
  53167. needAlphaBlending: boolean;
  53168. needAlphaTesting: boolean;
  53169. };
  53170. /**
  53171. * List of compilation checks
  53172. */
  53173. checks: {
  53174. emitVertex: boolean;
  53175. emitFragment: boolean;
  53176. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53177. };
  53178. /** Creates a new shared data */
  53179. constructor();
  53180. /**
  53181. * Emits console errors and exceptions if there is a failing check
  53182. */
  53183. emitErrors(): void;
  53184. }
  53185. }
  53186. declare module BABYLON {
  53187. /**
  53188. * Class used to store node based material build state
  53189. */
  53190. export class NodeMaterialBuildState {
  53191. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53192. supportUniformBuffers: boolean;
  53193. /**
  53194. * Gets the list of emitted attributes
  53195. */
  53196. attributes: string[];
  53197. /**
  53198. * Gets the list of emitted uniforms
  53199. */
  53200. uniforms: string[];
  53201. /**
  53202. * Gets the list of emitted constants
  53203. */
  53204. constants: string[];
  53205. /**
  53206. * Gets the list of emitted uniform buffers
  53207. */
  53208. uniformBuffers: string[];
  53209. /**
  53210. * Gets the list of emitted samplers
  53211. */
  53212. samplers: string[];
  53213. /**
  53214. * Gets the list of emitted functions
  53215. */
  53216. functions: {
  53217. [key: string]: string;
  53218. };
  53219. /**
  53220. * Gets the list of emitted extensions
  53221. */
  53222. extensions: {
  53223. [key: string]: string;
  53224. };
  53225. /**
  53226. * Gets the target of the compilation state
  53227. */
  53228. target: NodeMaterialBlockTargets;
  53229. /**
  53230. * Gets the list of emitted counters
  53231. */
  53232. counters: {
  53233. [key: string]: number;
  53234. };
  53235. /**
  53236. * Shared data between multiple NodeMaterialBuildState instances
  53237. */
  53238. sharedData: NodeMaterialBuildStateSharedData;
  53239. /** @hidden */
  53240. _vertexState: NodeMaterialBuildState;
  53241. /** @hidden */
  53242. _attributeDeclaration: string;
  53243. /** @hidden */
  53244. _uniformDeclaration: string;
  53245. /** @hidden */
  53246. _constantDeclaration: string;
  53247. /** @hidden */
  53248. _samplerDeclaration: string;
  53249. /** @hidden */
  53250. _varyingTransfer: string;
  53251. private _repeatableContentAnchorIndex;
  53252. /** @hidden */
  53253. _builtCompilationString: string;
  53254. /**
  53255. * Gets the emitted compilation strings
  53256. */
  53257. compilationString: string;
  53258. /**
  53259. * Finalize the compilation strings
  53260. * @param state defines the current compilation state
  53261. */
  53262. finalize(state: NodeMaterialBuildState): void;
  53263. /** @hidden */
  53264. readonly _repeatableContentAnchor: string;
  53265. /** @hidden */
  53266. _getFreeVariableName(prefix: string): string;
  53267. /** @hidden */
  53268. _getFreeDefineName(prefix: string): string;
  53269. /** @hidden */
  53270. _excludeVariableName(name: string): void;
  53271. /** @hidden */
  53272. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53273. /** @hidden */
  53274. _emitExtension(name: string, extension: string): void;
  53275. /** @hidden */
  53276. _emitFunction(name: string, code: string, comments: string): void;
  53277. /** @hidden */
  53278. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53279. replaceStrings?: {
  53280. search: RegExp;
  53281. replace: string;
  53282. }[];
  53283. repeatKey?: string;
  53284. }): string;
  53285. /** @hidden */
  53286. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53287. repeatKey?: string;
  53288. removeAttributes?: boolean;
  53289. removeUniforms?: boolean;
  53290. removeVaryings?: boolean;
  53291. removeIfDef?: boolean;
  53292. replaceStrings?: {
  53293. search: RegExp;
  53294. replace: string;
  53295. }[];
  53296. }, storeKey?: string): void;
  53297. /** @hidden */
  53298. _registerTempVariable(name: string): boolean;
  53299. /** @hidden */
  53300. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  53301. /** @hidden */
  53302. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  53303. }
  53304. }
  53305. declare module BABYLON {
  53306. /**
  53307. * Defines a block that can be used inside a node based material
  53308. */
  53309. export class NodeMaterialBlock {
  53310. private _buildId;
  53311. private _buildTarget;
  53312. private _target;
  53313. private _isFinalMerger;
  53314. private _isInput;
  53315. /** @hidden */
  53316. _codeVariableName: string;
  53317. /** @hidden */
  53318. _inputs: NodeMaterialConnectionPoint[];
  53319. /** @hidden */
  53320. _outputs: NodeMaterialConnectionPoint[];
  53321. /** @hidden */
  53322. _preparationId: number;
  53323. /**
  53324. * Gets or sets the name of the block
  53325. */
  53326. name: string;
  53327. /**
  53328. * Gets or sets the unique id of the node
  53329. */
  53330. uniqueId: number;
  53331. /**
  53332. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53333. */
  53334. readonly isFinalMerger: boolean;
  53335. /**
  53336. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  53337. */
  53338. readonly isInput: boolean;
  53339. /**
  53340. * Gets or sets the build Id
  53341. */
  53342. buildId: number;
  53343. /**
  53344. * Gets or sets the target of the block
  53345. */
  53346. target: NodeMaterialBlockTargets;
  53347. /**
  53348. * Gets the list of input points
  53349. */
  53350. readonly inputs: NodeMaterialConnectionPoint[];
  53351. /** Gets the list of output points */
  53352. readonly outputs: NodeMaterialConnectionPoint[];
  53353. /**
  53354. * Find an input by its name
  53355. * @param name defines the name of the input to look for
  53356. * @returns the input or null if not found
  53357. */
  53358. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53359. /**
  53360. * Find an output by its name
  53361. * @param name defines the name of the outputto look for
  53362. * @returns the output or null if not found
  53363. */
  53364. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53365. /**
  53366. * Creates a new NodeMaterialBlock
  53367. * @param name defines the block name
  53368. * @param target defines the target of that block (Vertex by default)
  53369. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53370. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  53371. */
  53372. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  53373. /**
  53374. * Initialize the block and prepare the context for build
  53375. * @param state defines the state that will be used for the build
  53376. */
  53377. initialize(state: NodeMaterialBuildState): void;
  53378. /**
  53379. * Bind data to effect. Will only be called for blocks with isBindable === true
  53380. * @param effect defines the effect to bind data to
  53381. * @param nodeMaterial defines the hosting NodeMaterial
  53382. * @param mesh defines the mesh that will be rendered
  53383. */
  53384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53385. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53386. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53387. protected _writeFloat(value: number): string;
  53388. /**
  53389. * Gets the current class name e.g. "NodeMaterialBlock"
  53390. * @returns the class name
  53391. */
  53392. getClassName(): string;
  53393. /**
  53394. * Register a new input. Must be called inside a block constructor
  53395. * @param name defines the connection point name
  53396. * @param type defines the connection point type
  53397. * @param isOptional defines a boolean indicating that this input can be omitted
  53398. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53399. * @returns the current block
  53400. */
  53401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53402. /**
  53403. * Register a new output. Must be called inside a block constructor
  53404. * @param name defines the connection point name
  53405. * @param type defines the connection point type
  53406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  53407. * @returns the current block
  53408. */
  53409. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53410. /**
  53411. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53412. * @param forOutput defines an optional connection point to check compatibility with
  53413. * @returns the first available input or null
  53414. */
  53415. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53416. /**
  53417. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53418. * @param forBlock defines an optional block to check compatibility with
  53419. * @returns the first available input or null
  53420. */
  53421. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53422. /**
  53423. * Gets the sibling of the given output
  53424. * @param current defines the current output
  53425. * @returns the next output in the list or null
  53426. */
  53427. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  53428. /**
  53429. * Connect current block with another block
  53430. * @param other defines the block to connect with
  53431. * @param options define the various options to help pick the right connections
  53432. * @returns the current block
  53433. */
  53434. connectTo(other: NodeMaterialBlock, options?: {
  53435. input?: string;
  53436. output?: string;
  53437. outputSwizzle?: string;
  53438. }): this | undefined;
  53439. protected _buildBlock(state: NodeMaterialBuildState): void;
  53440. /**
  53441. * Add uniforms, samplers and uniform buffers at compilation time
  53442. * @param state defines the state to update
  53443. * @param nodeMaterial defines the node material requesting the update
  53444. * @param defines defines the material defines to update
  53445. */
  53446. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53447. /**
  53448. * Add potential fallbacks if shader compilation fails
  53449. * @param mesh defines the mesh to be rendered
  53450. * @param fallbacks defines the current prioritized list of fallbacks
  53451. */
  53452. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53453. /**
  53454. * Initialize defines for shader compilation
  53455. * @param mesh defines the mesh to be rendered
  53456. * @param nodeMaterial defines the node material requesting the update
  53457. * @param defines defines the material defines to update
  53458. * @param useInstances specifies that instances should be used
  53459. */
  53460. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53461. /**
  53462. * Update defines for shader compilation
  53463. * @param mesh defines the mesh to be rendered
  53464. * @param nodeMaterial defines the node material requesting the update
  53465. * @param defines defines the material defines to update
  53466. * @param useInstances specifies that instances should be used
  53467. */
  53468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53469. /**
  53470. * Lets the block try to connect some inputs automatically
  53471. * @param material defines the hosting NodeMaterial
  53472. */
  53473. autoConfigure(material: NodeMaterial): void;
  53474. /**
  53475. * Function called when a block is declared as repeatable content generator
  53476. * @param vertexShaderState defines the current compilation state for the vertex shader
  53477. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53478. * @param mesh defines the mesh to be rendered
  53479. * @param defines defines the material defines to update
  53480. */
  53481. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53482. /**
  53483. * Checks if the block is ready
  53484. * @param mesh defines the mesh to be rendered
  53485. * @param nodeMaterial defines the node material requesting the update
  53486. * @param defines defines the material defines to update
  53487. * @param useInstances specifies that instances should be used
  53488. * @returns true if the block is ready
  53489. */
  53490. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53491. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  53492. private _processBuild;
  53493. /**
  53494. * Compile the current node and generate the shader code
  53495. * @param state defines the current compilation state (uniforms, samplers, current string)
  53496. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  53497. * @returns true if already built
  53498. */
  53499. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  53500. protected _inputRename(name: string): string;
  53501. protected _outputRename(name: string): string;
  53502. protected _dumpPropertiesCode(): string;
  53503. /** @hidden */
  53504. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  53505. /**
  53506. * Clone the current block to a new identical block
  53507. * @param scene defines the hosting scene
  53508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53509. * @returns a copy of the current block
  53510. */
  53511. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  53512. /**
  53513. * Serializes this block in a JSON representation
  53514. * @returns the serialized block object
  53515. */
  53516. serialize(): any;
  53517. /** @hidden */
  53518. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53519. }
  53520. }
  53521. declare module BABYLON {
  53522. /**
  53523. * Enum defining the type of animations supported by InputBlock
  53524. */
  53525. export enum AnimatedInputBlockTypes {
  53526. /** No animation */
  53527. None = 0,
  53528. /** Time based animation. Will only work for floats */
  53529. Time = 1
  53530. }
  53531. }
  53532. declare module BABYLON {
  53533. /**
  53534. * Block used to expose an input value
  53535. */
  53536. export class InputBlock extends NodeMaterialBlock {
  53537. private _mode;
  53538. private _associatedVariableName;
  53539. private _storedValue;
  53540. private _valueCallback;
  53541. private _type;
  53542. private _animationType;
  53543. /** Gets or set a value used to limit the range of float values */
  53544. min: number;
  53545. /** Gets or set a value used to limit the range of float values */
  53546. max: number;
  53547. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  53548. matrixMode: number;
  53549. /** @hidden */
  53550. _systemValue: Nullable<NodeMaterialSystemValues>;
  53551. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  53552. visibleInInspector: boolean;
  53553. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  53554. isConstant: boolean;
  53555. /**
  53556. * Gets or sets the connection point type (default is float)
  53557. */
  53558. readonly type: NodeMaterialBlockConnectionPointTypes;
  53559. /**
  53560. * Creates a new InputBlock
  53561. * @param name defines the block name
  53562. * @param target defines the target of that block (Vertex by default)
  53563. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  53564. */
  53565. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  53566. /**
  53567. * Gets the output component
  53568. */
  53569. readonly output: NodeMaterialConnectionPoint;
  53570. /**
  53571. * Set the source of this connection point to a vertex attribute
  53572. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53573. * @returns the current connection point
  53574. */
  53575. setAsAttribute(attributeName?: string): InputBlock;
  53576. /**
  53577. * Set the source of this connection point to a system value
  53578. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  53579. * @returns the current connection point
  53580. */
  53581. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  53582. /**
  53583. * Gets or sets the value of that point.
  53584. * Please note that this value will be ignored if valueCallback is defined
  53585. */
  53586. value: any;
  53587. /**
  53588. * Gets or sets a callback used to get the value of that point.
  53589. * Please note that setting this value will force the connection point to ignore the value property
  53590. */
  53591. valueCallback: () => any;
  53592. /**
  53593. * Gets or sets the associated variable name in the shader
  53594. */
  53595. associatedVariableName: string;
  53596. /** Gets or sets the type of animation applied to the input */
  53597. animationType: AnimatedInputBlockTypes;
  53598. /**
  53599. * Gets a boolean indicating that this connection point not defined yet
  53600. */
  53601. readonly isUndefined: boolean;
  53602. /**
  53603. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53604. * In this case the connection point name must be the name of the uniform to use.
  53605. * Can only be set on inputs
  53606. */
  53607. isUniform: boolean;
  53608. /**
  53609. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53610. * In this case the connection point name must be the name of the attribute to use
  53611. * Can only be set on inputs
  53612. */
  53613. isAttribute: boolean;
  53614. /**
  53615. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53616. * Can only be set on exit points
  53617. */
  53618. isVarying: boolean;
  53619. /**
  53620. * Gets a boolean indicating that the current connection point is a system value
  53621. */
  53622. readonly isSystemValue: boolean;
  53623. /**
  53624. * Gets or sets the current well known value or null if not defined as a system value
  53625. */
  53626. systemValue: Nullable<NodeMaterialSystemValues>;
  53627. /**
  53628. * Gets the current class name
  53629. * @returns the class name
  53630. */
  53631. getClassName(): string;
  53632. /**
  53633. * Animate the input if animationType !== None
  53634. * @param scene defines the rendering scene
  53635. */
  53636. animate(scene: Scene): void;
  53637. private _emitDefine;
  53638. initialize(state: NodeMaterialBuildState): void;
  53639. /**
  53640. * Set the input block to its default value (based on its type)
  53641. */
  53642. setDefaultValue(): void;
  53643. private _emitConstant;
  53644. private _emit;
  53645. /** @hidden */
  53646. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53647. /** @hidden */
  53648. _transmit(effect: Effect, scene: Scene): void;
  53649. protected _buildBlock(state: NodeMaterialBuildState): void;
  53650. protected _dumpPropertiesCode(): string;
  53651. serialize(): any;
  53652. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53653. }
  53654. }
  53655. declare module BABYLON {
  53656. /**
  53657. * Defines a connection point for a block
  53658. */
  53659. export class NodeMaterialConnectionPoint {
  53660. /** @hidden */
  53661. _ownerBlock: NodeMaterialBlock;
  53662. /** @hidden */
  53663. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53664. private _endpoints;
  53665. private _associatedVariableName;
  53666. /** @hidden */
  53667. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53668. /** @hidden */
  53669. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53670. private _type;
  53671. /** @hidden */
  53672. _enforceAssociatedVariableName: boolean;
  53673. /**
  53674. * Gets or sets the additional types supported by this connection point
  53675. */
  53676. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53677. /**
  53678. * Gets or sets the additional types excluded by this connection point
  53679. */
  53680. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  53681. /**
  53682. * Gets or sets the associated variable name in the shader
  53683. */
  53684. associatedVariableName: string;
  53685. /**
  53686. * Gets or sets the connection point type (default is float)
  53687. */
  53688. type: NodeMaterialBlockConnectionPointTypes;
  53689. /**
  53690. * Gets or sets the connection point name
  53691. */
  53692. name: string;
  53693. /**
  53694. * Gets or sets a boolean indicating that this connection point can be omitted
  53695. */
  53696. isOptional: boolean;
  53697. /**
  53698. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53699. */
  53700. define: string;
  53701. /** Gets or sets the target of that connection point */
  53702. target: NodeMaterialBlockTargets;
  53703. /**
  53704. * Gets a boolean indicating that the current point is connected
  53705. */
  53706. readonly isConnected: boolean;
  53707. /**
  53708. * Gets a boolean indicating that the current point is connected to an input block
  53709. */
  53710. readonly isConnectedToInputBlock: boolean;
  53711. /**
  53712. * Gets a the connected input block (if any)
  53713. */
  53714. readonly connectInputBlock: Nullable<InputBlock>;
  53715. /** Get the other side of the connection (if any) */
  53716. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53717. /** Get the block that owns this connection point */
  53718. readonly ownerBlock: NodeMaterialBlock;
  53719. /** Get the block connected on the other side of this connection (if any) */
  53720. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53721. /** Get the block connected on the endpoints of this connection (if any) */
  53722. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53723. /** Gets the list of connected endpoints */
  53724. readonly endpoints: NodeMaterialConnectionPoint[];
  53725. /** Gets a boolean indicating if that output point is connected to at least one input */
  53726. readonly hasEndpoints: boolean;
  53727. /**
  53728. * Creates a new connection point
  53729. * @param name defines the connection point name
  53730. * @param ownerBlock defines the block hosting this connection point
  53731. */
  53732. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53733. /**
  53734. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53735. * @returns the class name
  53736. */
  53737. getClassName(): string;
  53738. /**
  53739. * Gets an boolean indicating if the current point can be connected to another point
  53740. * @param connectionPoint defines the other connection point
  53741. * @returns true if the connection is possible
  53742. */
  53743. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53744. /**
  53745. * Connect this point to another connection point
  53746. * @param connectionPoint defines the other connection point
  53747. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53748. * @returns the current connection point
  53749. */
  53750. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53751. /**
  53752. * Disconnect this point from one of his endpoint
  53753. * @param endpoint defines the other connection point
  53754. * @returns the current connection point
  53755. */
  53756. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53757. /**
  53758. * Serializes this point in a JSON representation
  53759. * @returns the serialized point object
  53760. */
  53761. serialize(): any;
  53762. }
  53763. }
  53764. declare module BABYLON {
  53765. /**
  53766. * Block used to add support for vertex skinning (bones)
  53767. */
  53768. export class BonesBlock extends NodeMaterialBlock {
  53769. /**
  53770. * Creates a new BonesBlock
  53771. * @param name defines the block name
  53772. */
  53773. constructor(name: string);
  53774. /**
  53775. * Initialize the block and prepare the context for build
  53776. * @param state defines the state that will be used for the build
  53777. */
  53778. initialize(state: NodeMaterialBuildState): void;
  53779. /**
  53780. * Gets the current class name
  53781. * @returns the class name
  53782. */
  53783. getClassName(): string;
  53784. /**
  53785. * Gets the matrix indices input component
  53786. */
  53787. readonly matricesIndices: NodeMaterialConnectionPoint;
  53788. /**
  53789. * Gets the matrix weights input component
  53790. */
  53791. readonly matricesWeights: NodeMaterialConnectionPoint;
  53792. /**
  53793. * Gets the extra matrix indices input component
  53794. */
  53795. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53796. /**
  53797. * Gets the extra matrix weights input component
  53798. */
  53799. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53800. /**
  53801. * Gets the world input component
  53802. */
  53803. readonly world: NodeMaterialConnectionPoint;
  53804. /**
  53805. * Gets the output component
  53806. */
  53807. readonly output: NodeMaterialConnectionPoint;
  53808. autoConfigure(material: NodeMaterial): void;
  53809. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53812. protected _buildBlock(state: NodeMaterialBuildState): this;
  53813. }
  53814. }
  53815. declare module BABYLON {
  53816. /**
  53817. * Block used to add support for instances
  53818. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53819. */
  53820. export class InstancesBlock extends NodeMaterialBlock {
  53821. /**
  53822. * Creates a new InstancesBlock
  53823. * @param name defines the block name
  53824. */
  53825. constructor(name: string);
  53826. /**
  53827. * Gets the current class name
  53828. * @returns the class name
  53829. */
  53830. getClassName(): string;
  53831. /**
  53832. * Gets the first world row input component
  53833. */
  53834. readonly world0: NodeMaterialConnectionPoint;
  53835. /**
  53836. * Gets the second world row input component
  53837. */
  53838. readonly world1: NodeMaterialConnectionPoint;
  53839. /**
  53840. * Gets the third world row input component
  53841. */
  53842. readonly world2: NodeMaterialConnectionPoint;
  53843. /**
  53844. * Gets the forth world row input component
  53845. */
  53846. readonly world3: NodeMaterialConnectionPoint;
  53847. /**
  53848. * Gets the world input component
  53849. */
  53850. readonly world: NodeMaterialConnectionPoint;
  53851. /**
  53852. * Gets the output component
  53853. */
  53854. readonly output: NodeMaterialConnectionPoint;
  53855. autoConfigure(material: NodeMaterial): void;
  53856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53857. protected _buildBlock(state: NodeMaterialBuildState): this;
  53858. }
  53859. }
  53860. declare module BABYLON {
  53861. /**
  53862. * Block used to add morph targets support to vertex shader
  53863. */
  53864. export class MorphTargetsBlock extends NodeMaterialBlock {
  53865. private _repeatableContentAnchor;
  53866. private _repeatebleContentGenerated;
  53867. /**
  53868. * Create a new MorphTargetsBlock
  53869. * @param name defines the block name
  53870. */
  53871. constructor(name: string);
  53872. /**
  53873. * Gets the current class name
  53874. * @returns the class name
  53875. */
  53876. getClassName(): string;
  53877. /**
  53878. * Gets the position input component
  53879. */
  53880. readonly position: NodeMaterialConnectionPoint;
  53881. /**
  53882. * Gets the normal input component
  53883. */
  53884. readonly normal: NodeMaterialConnectionPoint;
  53885. /**
  53886. * Gets the tangent input component
  53887. */
  53888. readonly tangent: NodeMaterialConnectionPoint;
  53889. /**
  53890. * Gets the tangent input component
  53891. */
  53892. readonly uv: NodeMaterialConnectionPoint;
  53893. /**
  53894. * Gets the position output component
  53895. */
  53896. readonly positionOutput: NodeMaterialConnectionPoint;
  53897. /**
  53898. * Gets the normal output component
  53899. */
  53900. readonly normalOutput: NodeMaterialConnectionPoint;
  53901. /**
  53902. * Gets the tangent output component
  53903. */
  53904. readonly tangentOutput: NodeMaterialConnectionPoint;
  53905. /**
  53906. * Gets the tangent output component
  53907. */
  53908. readonly uvOutput: NodeMaterialConnectionPoint;
  53909. initialize(state: NodeMaterialBuildState): void;
  53910. autoConfigure(material: NodeMaterial): void;
  53911. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53912. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53913. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53914. protected _buildBlock(state: NodeMaterialBuildState): this;
  53915. }
  53916. }
  53917. declare module BABYLON {
  53918. /**
  53919. * Block used to get data information from a light
  53920. */
  53921. export class LightInformationBlock extends NodeMaterialBlock {
  53922. private _lightDataUniformName;
  53923. private _lightColorUniformName;
  53924. private _lightTypeDefineName;
  53925. /**
  53926. * Gets or sets the light associated with this block
  53927. */
  53928. light: Nullable<Light>;
  53929. /**
  53930. * Creates a new LightInformationBlock
  53931. * @param name defines the block name
  53932. */
  53933. constructor(name: string);
  53934. /**
  53935. * Gets the current class name
  53936. * @returns the class name
  53937. */
  53938. getClassName(): string;
  53939. /**
  53940. * Gets the world position input component
  53941. */
  53942. readonly worldPosition: NodeMaterialConnectionPoint;
  53943. /**
  53944. * Gets the direction output component
  53945. */
  53946. readonly direction: NodeMaterialConnectionPoint;
  53947. /**
  53948. * Gets the direction output component
  53949. */
  53950. readonly color: NodeMaterialConnectionPoint;
  53951. /**
  53952. * Gets the direction output component
  53953. */
  53954. readonly intensity: NodeMaterialConnectionPoint;
  53955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53957. protected _buildBlock(state: NodeMaterialBuildState): this;
  53958. serialize(): any;
  53959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53960. }
  53961. }
  53962. declare module BABYLON {
  53963. /**
  53964. * Block used to add image processing support to fragment shader
  53965. */
  53966. export class ImageProcessingBlock extends NodeMaterialBlock {
  53967. /**
  53968. * Create a new ImageProcessingBlock
  53969. * @param name defines the block name
  53970. */
  53971. constructor(name: string);
  53972. /**
  53973. * Gets the current class name
  53974. * @returns the class name
  53975. */
  53976. getClassName(): string;
  53977. /**
  53978. * Gets the color input component
  53979. */
  53980. readonly color: NodeMaterialConnectionPoint;
  53981. /**
  53982. * Gets the output component
  53983. */
  53984. readonly output: NodeMaterialConnectionPoint;
  53985. /**
  53986. * Initialize the block and prepare the context for build
  53987. * @param state defines the state that will be used for the build
  53988. */
  53989. initialize(state: NodeMaterialBuildState): void;
  53990. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53992. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53993. protected _buildBlock(state: NodeMaterialBuildState): this;
  53994. }
  53995. }
  53996. declare module BABYLON {
  53997. /**
  53998. * Block used to pertub normals based on a normal map
  53999. */
  54000. export class PerturbNormalBlock extends NodeMaterialBlock {
  54001. private _tangentSpaceParameterName;
  54002. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  54003. invertX: boolean;
  54004. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  54005. invertY: boolean;
  54006. /**
  54007. * Create a new PerturbNormalBlock
  54008. * @param name defines the block name
  54009. */
  54010. constructor(name: string);
  54011. /**
  54012. * Gets the current class name
  54013. * @returns the class name
  54014. */
  54015. getClassName(): string;
  54016. /**
  54017. * Gets the world position input component
  54018. */
  54019. readonly worldPosition: NodeMaterialConnectionPoint;
  54020. /**
  54021. * Gets the world normal input component
  54022. */
  54023. readonly worldNormal: NodeMaterialConnectionPoint;
  54024. /**
  54025. * Gets the uv input component
  54026. */
  54027. readonly uv: NodeMaterialConnectionPoint;
  54028. /**
  54029. * Gets the normal map color input component
  54030. */
  54031. readonly normalMapColor: NodeMaterialConnectionPoint;
  54032. /**
  54033. * Gets the strength input component
  54034. */
  54035. readonly strength: NodeMaterialConnectionPoint;
  54036. /**
  54037. * Gets the output component
  54038. */
  54039. readonly output: NodeMaterialConnectionPoint;
  54040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54042. autoConfigure(material: NodeMaterial): void;
  54043. protected _buildBlock(state: NodeMaterialBuildState): this;
  54044. protected _dumpPropertiesCode(): string;
  54045. serialize(): any;
  54046. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54047. }
  54048. }
  54049. declare module BABYLON {
  54050. /**
  54051. * Block used to discard a pixel if a value is smaller than a cutoff
  54052. */
  54053. export class DiscardBlock extends NodeMaterialBlock {
  54054. /**
  54055. * Create a new DiscardBlock
  54056. * @param name defines the block name
  54057. */
  54058. constructor(name: string);
  54059. /**
  54060. * Gets the current class name
  54061. * @returns the class name
  54062. */
  54063. getClassName(): string;
  54064. /**
  54065. * Gets the color input component
  54066. */
  54067. readonly value: NodeMaterialConnectionPoint;
  54068. /**
  54069. * Gets the cutoff input component
  54070. */
  54071. readonly cutoff: NodeMaterialConnectionPoint;
  54072. protected _buildBlock(state: NodeMaterialBuildState): this;
  54073. }
  54074. }
  54075. declare module BABYLON {
  54076. /**
  54077. * Block used to add support for scene fog
  54078. */
  54079. export class FogBlock extends NodeMaterialBlock {
  54080. private _fogDistanceName;
  54081. private _fogParameters;
  54082. /**
  54083. * Create a new FogBlock
  54084. * @param name defines the block name
  54085. */
  54086. constructor(name: string);
  54087. /**
  54088. * Gets the current class name
  54089. * @returns the class name
  54090. */
  54091. getClassName(): string;
  54092. /**
  54093. * Gets the world position input component
  54094. */
  54095. readonly worldPosition: NodeMaterialConnectionPoint;
  54096. /**
  54097. * Gets the view input component
  54098. */
  54099. readonly view: NodeMaterialConnectionPoint;
  54100. /**
  54101. * Gets the color input component
  54102. */
  54103. readonly input: NodeMaterialConnectionPoint;
  54104. /**
  54105. * Gets the fog color input component
  54106. */
  54107. readonly fogColor: NodeMaterialConnectionPoint;
  54108. /**
  54109. * Gets the output component
  54110. */
  54111. readonly output: NodeMaterialConnectionPoint;
  54112. autoConfigure(material: NodeMaterial): void;
  54113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54115. protected _buildBlock(state: NodeMaterialBuildState): this;
  54116. }
  54117. }
  54118. declare module BABYLON {
  54119. /**
  54120. * Block used to add light in the fragment shader
  54121. */
  54122. export class LightBlock extends NodeMaterialBlock {
  54123. private _lightId;
  54124. /**
  54125. * Gets or sets the light associated with this block
  54126. */
  54127. light: Nullable<Light>;
  54128. /**
  54129. * Create a new LightBlock
  54130. * @param name defines the block name
  54131. */
  54132. constructor(name: string);
  54133. /**
  54134. * Gets the current class name
  54135. * @returns the class name
  54136. */
  54137. getClassName(): string;
  54138. /**
  54139. * Gets the world position input component
  54140. */
  54141. readonly worldPosition: NodeMaterialConnectionPoint;
  54142. /**
  54143. * Gets the world normal input component
  54144. */
  54145. readonly worldNormal: NodeMaterialConnectionPoint;
  54146. /**
  54147. * Gets the camera (or eye) position component
  54148. */
  54149. readonly cameraPosition: NodeMaterialConnectionPoint;
  54150. /**
  54151. * Gets the glossiness component
  54152. */
  54153. readonly glossiness: NodeMaterialConnectionPoint;
  54154. /**
  54155. * Gets the diffuse color component
  54156. */
  54157. readonly diffuseColor: NodeMaterialConnectionPoint;
  54158. /**
  54159. * Gets the specular color component
  54160. */
  54161. readonly specularColor: NodeMaterialConnectionPoint;
  54162. /**
  54163. * Gets the diffuse output component
  54164. */
  54165. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Gets the specular output component
  54168. */
  54169. readonly specularOutput: NodeMaterialConnectionPoint;
  54170. autoConfigure(material: NodeMaterial): void;
  54171. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54172. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54173. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54174. private _injectVertexCode;
  54175. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54176. serialize(): any;
  54177. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54178. }
  54179. }
  54180. declare module BABYLON {
  54181. /**
  54182. * Block used to multiply 2 values
  54183. */
  54184. export class MultiplyBlock extends NodeMaterialBlock {
  54185. /**
  54186. * Creates a new MultiplyBlock
  54187. * @param name defines the block name
  54188. */
  54189. constructor(name: string);
  54190. /**
  54191. * Gets the current class name
  54192. * @returns the class name
  54193. */
  54194. getClassName(): string;
  54195. /**
  54196. * Gets the left operand input component
  54197. */
  54198. readonly left: NodeMaterialConnectionPoint;
  54199. /**
  54200. * Gets the right operand input component
  54201. */
  54202. readonly right: NodeMaterialConnectionPoint;
  54203. /**
  54204. * Gets the output component
  54205. */
  54206. readonly output: NodeMaterialConnectionPoint;
  54207. protected _buildBlock(state: NodeMaterialBuildState): this;
  54208. }
  54209. }
  54210. declare module BABYLON {
  54211. /**
  54212. * Block used to add 2 vectors
  54213. */
  54214. export class AddBlock extends NodeMaterialBlock {
  54215. /**
  54216. * Creates a new AddBlock
  54217. * @param name defines the block name
  54218. */
  54219. constructor(name: string);
  54220. /**
  54221. * Gets the current class name
  54222. * @returns the class name
  54223. */
  54224. getClassName(): string;
  54225. /**
  54226. * Gets the left operand input component
  54227. */
  54228. readonly left: NodeMaterialConnectionPoint;
  54229. /**
  54230. * Gets the right operand input component
  54231. */
  54232. readonly right: NodeMaterialConnectionPoint;
  54233. /**
  54234. * Gets the output component
  54235. */
  54236. readonly output: NodeMaterialConnectionPoint;
  54237. protected _buildBlock(state: NodeMaterialBuildState): this;
  54238. }
  54239. }
  54240. declare module BABYLON {
  54241. /**
  54242. * Block used to scale a vector by a float
  54243. */
  54244. export class ScaleBlock extends NodeMaterialBlock {
  54245. /**
  54246. * Creates a new ScaleBlock
  54247. * @param name defines the block name
  54248. */
  54249. constructor(name: string);
  54250. /**
  54251. * Gets the current class name
  54252. * @returns the class name
  54253. */
  54254. getClassName(): string;
  54255. /**
  54256. * Gets the input component
  54257. */
  54258. readonly input: NodeMaterialConnectionPoint;
  54259. /**
  54260. * Gets the factor input component
  54261. */
  54262. readonly factor: NodeMaterialConnectionPoint;
  54263. /**
  54264. * Gets the output component
  54265. */
  54266. readonly output: NodeMaterialConnectionPoint;
  54267. protected _buildBlock(state: NodeMaterialBuildState): this;
  54268. }
  54269. }
  54270. declare module BABYLON {
  54271. /**
  54272. * Block used to clamp a float
  54273. */
  54274. export class ClampBlock extends NodeMaterialBlock {
  54275. /** Gets or sets the minimum range */
  54276. minimum: number;
  54277. /** Gets or sets the maximum range */
  54278. maximum: number;
  54279. /**
  54280. * Creates a new ClampBlock
  54281. * @param name defines the block name
  54282. */
  54283. constructor(name: string);
  54284. /**
  54285. * Gets the current class name
  54286. * @returns the class name
  54287. */
  54288. getClassName(): string;
  54289. /**
  54290. * Gets the value input component
  54291. */
  54292. readonly value: NodeMaterialConnectionPoint;
  54293. /**
  54294. * Gets the output component
  54295. */
  54296. readonly output: NodeMaterialConnectionPoint;
  54297. protected _buildBlock(state: NodeMaterialBuildState): this;
  54298. protected _dumpPropertiesCode(): string;
  54299. serialize(): any;
  54300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54301. }
  54302. }
  54303. declare module BABYLON {
  54304. /**
  54305. * Block used to apply a cross product between 2 vectors
  54306. */
  54307. export class CrossBlock extends NodeMaterialBlock {
  54308. /**
  54309. * Creates a new CrossBlock
  54310. * @param name defines the block name
  54311. */
  54312. constructor(name: string);
  54313. /**
  54314. * Gets the current class name
  54315. * @returns the class name
  54316. */
  54317. getClassName(): string;
  54318. /**
  54319. * Gets the left operand input component
  54320. */
  54321. readonly left: NodeMaterialConnectionPoint;
  54322. /**
  54323. * Gets the right operand input component
  54324. */
  54325. readonly right: NodeMaterialConnectionPoint;
  54326. /**
  54327. * Gets the output component
  54328. */
  54329. readonly output: NodeMaterialConnectionPoint;
  54330. protected _buildBlock(state: NodeMaterialBuildState): this;
  54331. }
  54332. }
  54333. declare module BABYLON {
  54334. /**
  54335. * Block used to apply a dot product between 2 vectors
  54336. */
  54337. export class DotBlock extends NodeMaterialBlock {
  54338. /**
  54339. * Creates a new DotBlock
  54340. * @param name defines the block name
  54341. */
  54342. constructor(name: string);
  54343. /**
  54344. * Gets the current class name
  54345. * @returns the class name
  54346. */
  54347. getClassName(): string;
  54348. /**
  54349. * Gets the left operand input component
  54350. */
  54351. readonly left: NodeMaterialConnectionPoint;
  54352. /**
  54353. * Gets the right operand input component
  54354. */
  54355. readonly right: NodeMaterialConnectionPoint;
  54356. /**
  54357. * Gets the output component
  54358. */
  54359. readonly output: NodeMaterialConnectionPoint;
  54360. protected _buildBlock(state: NodeMaterialBuildState): this;
  54361. }
  54362. }
  54363. declare module BABYLON {
  54364. /**
  54365. * Block used to remap a float from a range to a new one
  54366. */
  54367. export class RemapBlock extends NodeMaterialBlock {
  54368. /**
  54369. * Gets or sets the source range
  54370. */
  54371. sourceRange: Vector2;
  54372. /**
  54373. * Gets or sets the target range
  54374. */
  54375. targetRange: Vector2;
  54376. /**
  54377. * Creates a new RemapBlock
  54378. * @param name defines the block name
  54379. */
  54380. constructor(name: string);
  54381. /**
  54382. * Gets the current class name
  54383. * @returns the class name
  54384. */
  54385. getClassName(): string;
  54386. /**
  54387. * Gets the input component
  54388. */
  54389. readonly input: NodeMaterialConnectionPoint;
  54390. /**
  54391. * Gets the source min input component
  54392. */
  54393. readonly sourceMin: NodeMaterialConnectionPoint;
  54394. /**
  54395. * Gets the source max input component
  54396. */
  54397. readonly sourceMax: NodeMaterialConnectionPoint;
  54398. /**
  54399. * Gets the target min input component
  54400. */
  54401. readonly targetMin: NodeMaterialConnectionPoint;
  54402. /**
  54403. * Gets the target max input component
  54404. */
  54405. readonly targetMax: NodeMaterialConnectionPoint;
  54406. /**
  54407. * Gets the output component
  54408. */
  54409. readonly output: NodeMaterialConnectionPoint;
  54410. protected _buildBlock(state: NodeMaterialBuildState): this;
  54411. protected _dumpPropertiesCode(): string;
  54412. serialize(): any;
  54413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54414. }
  54415. }
  54416. declare module BABYLON {
  54417. /**
  54418. * Block used to normalize a vector
  54419. */
  54420. export class NormalizeBlock extends NodeMaterialBlock {
  54421. /**
  54422. * Creates a new NormalizeBlock
  54423. * @param name defines the block name
  54424. */
  54425. constructor(name: string);
  54426. /**
  54427. * Gets the current class name
  54428. * @returns the class name
  54429. */
  54430. getClassName(): string;
  54431. /**
  54432. * Gets the input component
  54433. */
  54434. readonly input: NodeMaterialConnectionPoint;
  54435. /**
  54436. * Gets the output component
  54437. */
  54438. readonly output: NodeMaterialConnectionPoint;
  54439. protected _buildBlock(state: NodeMaterialBuildState): this;
  54440. }
  54441. }
  54442. declare module BABYLON {
  54443. /**
  54444. * Operations supported by the Trigonometry block
  54445. */
  54446. export enum TrigonometryBlockOperations {
  54447. /** Cos */
  54448. Cos = 0,
  54449. /** Sin */
  54450. Sin = 1,
  54451. /** Abs */
  54452. Abs = 2,
  54453. /** Exp */
  54454. Exp = 3,
  54455. /** Exp2 */
  54456. Exp2 = 4,
  54457. /** Round */
  54458. Round = 5,
  54459. /** Floor */
  54460. Floor = 6,
  54461. /** Ceiling */
  54462. Ceiling = 7,
  54463. /** Square root */
  54464. Sqrt = 8
  54465. }
  54466. /**
  54467. * Block used to apply trigonometry operation to floats
  54468. */
  54469. export class TrigonometryBlock extends NodeMaterialBlock {
  54470. /**
  54471. * Gets or sets the operation applied by the block
  54472. */
  54473. operation: TrigonometryBlockOperations;
  54474. /**
  54475. * Creates a new TrigonometryBlock
  54476. * @param name defines the block name
  54477. */
  54478. constructor(name: string);
  54479. /**
  54480. * Gets the current class name
  54481. * @returns the class name
  54482. */
  54483. getClassName(): string;
  54484. /**
  54485. * Gets the input component
  54486. */
  54487. readonly input: NodeMaterialConnectionPoint;
  54488. /**
  54489. * Gets the output component
  54490. */
  54491. readonly output: NodeMaterialConnectionPoint;
  54492. protected _buildBlock(state: NodeMaterialBuildState): this;
  54493. serialize(): any;
  54494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54495. }
  54496. }
  54497. declare module BABYLON {
  54498. /**
  54499. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54500. */
  54501. export class ColorMergerBlock extends NodeMaterialBlock {
  54502. /**
  54503. * Create a new ColorMergerBlock
  54504. * @param name defines the block name
  54505. */
  54506. constructor(name: string);
  54507. /**
  54508. * Gets the current class name
  54509. * @returns the class name
  54510. */
  54511. getClassName(): string;
  54512. /**
  54513. * Gets the r component (input)
  54514. */
  54515. readonly r: NodeMaterialConnectionPoint;
  54516. /**
  54517. * Gets the g component (input)
  54518. */
  54519. readonly g: NodeMaterialConnectionPoint;
  54520. /**
  54521. * Gets the b component (input)
  54522. */
  54523. readonly b: NodeMaterialConnectionPoint;
  54524. /**
  54525. * Gets the a component (input)
  54526. */
  54527. readonly a: NodeMaterialConnectionPoint;
  54528. /**
  54529. * Gets the rgba component (output)
  54530. */
  54531. readonly rgba: NodeMaterialConnectionPoint;
  54532. /**
  54533. * Gets the rgb component (output)
  54534. */
  54535. readonly rgb: NodeMaterialConnectionPoint;
  54536. protected _buildBlock(state: NodeMaterialBuildState): this;
  54537. }
  54538. }
  54539. declare module BABYLON {
  54540. /**
  54541. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54542. */
  54543. export class VectorMergerBlock extends NodeMaterialBlock {
  54544. /**
  54545. * Create a new VectorMergerBlock
  54546. * @param name defines the block name
  54547. */
  54548. constructor(name: string);
  54549. /**
  54550. * Gets the current class name
  54551. * @returns the class name
  54552. */
  54553. getClassName(): string;
  54554. /**
  54555. * Gets the x component (input)
  54556. */
  54557. readonly x: NodeMaterialConnectionPoint;
  54558. /**
  54559. * Gets the y component (input)
  54560. */
  54561. readonly y: NodeMaterialConnectionPoint;
  54562. /**
  54563. * Gets the z component (input)
  54564. */
  54565. readonly z: NodeMaterialConnectionPoint;
  54566. /**
  54567. * Gets the w component (input)
  54568. */
  54569. readonly w: NodeMaterialConnectionPoint;
  54570. /**
  54571. * Gets the xyzw component (output)
  54572. */
  54573. readonly xyzw: NodeMaterialConnectionPoint;
  54574. /**
  54575. * Gets the xyz component (output)
  54576. */
  54577. readonly xyz: NodeMaterialConnectionPoint;
  54578. /**
  54579. * Gets the xy component (output)
  54580. */
  54581. readonly xy: NodeMaterialConnectionPoint;
  54582. protected _buildBlock(state: NodeMaterialBuildState): this;
  54583. }
  54584. }
  54585. declare module BABYLON {
  54586. /**
  54587. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  54588. */
  54589. export class ColorSplitterBlock extends NodeMaterialBlock {
  54590. /**
  54591. * Create a new ColorSplitterBlock
  54592. * @param name defines the block name
  54593. */
  54594. constructor(name: string);
  54595. /**
  54596. * Gets the current class name
  54597. * @returns the class name
  54598. */
  54599. getClassName(): string;
  54600. /**
  54601. * Gets the rgba component (input)
  54602. */
  54603. readonly rgba: NodeMaterialConnectionPoint;
  54604. /**
  54605. * Gets the rgb component (input)
  54606. */
  54607. readonly rgbIn: NodeMaterialConnectionPoint;
  54608. /**
  54609. * Gets the rgb component (output)
  54610. */
  54611. readonly rgbOut: NodeMaterialConnectionPoint;
  54612. /**
  54613. * Gets the r component (output)
  54614. */
  54615. readonly r: NodeMaterialConnectionPoint;
  54616. /**
  54617. * Gets the g component (output)
  54618. */
  54619. readonly g: NodeMaterialConnectionPoint;
  54620. /**
  54621. * Gets the b component (output)
  54622. */
  54623. readonly b: NodeMaterialConnectionPoint;
  54624. /**
  54625. * Gets the a component (output)
  54626. */
  54627. readonly a: NodeMaterialConnectionPoint;
  54628. protected _inputRename(name: string): string;
  54629. protected _outputRename(name: string): string;
  54630. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54631. }
  54632. }
  54633. declare module BABYLON {
  54634. /**
  54635. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  54636. */
  54637. export class VectorSplitterBlock extends NodeMaterialBlock {
  54638. /**
  54639. * Create a new VectorSplitterBlock
  54640. * @param name defines the block name
  54641. */
  54642. constructor(name: string);
  54643. /**
  54644. * Gets the current class name
  54645. * @returns the class name
  54646. */
  54647. getClassName(): string;
  54648. /**
  54649. * Gets the xyzw component (input)
  54650. */
  54651. readonly xyzw: NodeMaterialConnectionPoint;
  54652. /**
  54653. * Gets the xyz component (input)
  54654. */
  54655. readonly xyzIn: NodeMaterialConnectionPoint;
  54656. /**
  54657. * Gets the xy component (input)
  54658. */
  54659. readonly xyIn: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the xyz component (output)
  54662. */
  54663. readonly xyzOut: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the xy component (output)
  54666. */
  54667. readonly xyOut: NodeMaterialConnectionPoint;
  54668. /**
  54669. * Gets the x component (output)
  54670. */
  54671. readonly x: NodeMaterialConnectionPoint;
  54672. /**
  54673. * Gets the y component (output)
  54674. */
  54675. readonly y: NodeMaterialConnectionPoint;
  54676. /**
  54677. * Gets the z component (output)
  54678. */
  54679. readonly z: NodeMaterialConnectionPoint;
  54680. /**
  54681. * Gets the w component (output)
  54682. */
  54683. readonly w: NodeMaterialConnectionPoint;
  54684. protected _inputRename(name: string): string;
  54685. protected _outputRename(name: string): string;
  54686. protected _buildBlock(state: NodeMaterialBuildState): this;
  54687. }
  54688. }
  54689. declare module BABYLON {
  54690. /**
  54691. * Block used to lerp 2 values
  54692. */
  54693. export class LerpBlock extends NodeMaterialBlock {
  54694. /**
  54695. * Creates a new LerpBlock
  54696. * @param name defines the block name
  54697. */
  54698. constructor(name: string);
  54699. /**
  54700. * Gets the current class name
  54701. * @returns the class name
  54702. */
  54703. getClassName(): string;
  54704. /**
  54705. * Gets the left operand input component
  54706. */
  54707. readonly left: NodeMaterialConnectionPoint;
  54708. /**
  54709. * Gets the right operand input component
  54710. */
  54711. readonly right: NodeMaterialConnectionPoint;
  54712. /**
  54713. * Gets the gradient operand input component
  54714. */
  54715. readonly gradient: NodeMaterialConnectionPoint;
  54716. /**
  54717. * Gets the output component
  54718. */
  54719. readonly output: NodeMaterialConnectionPoint;
  54720. protected _buildBlock(state: NodeMaterialBuildState): this;
  54721. }
  54722. }
  54723. declare module BABYLON {
  54724. /**
  54725. * Block used to divide 2 vectors
  54726. */
  54727. export class DivideBlock extends NodeMaterialBlock {
  54728. /**
  54729. * Creates a new DivideBlock
  54730. * @param name defines the block name
  54731. */
  54732. constructor(name: string);
  54733. /**
  54734. * Gets the current class name
  54735. * @returns the class name
  54736. */
  54737. getClassName(): string;
  54738. /**
  54739. * Gets the left operand input component
  54740. */
  54741. readonly left: NodeMaterialConnectionPoint;
  54742. /**
  54743. * Gets the right operand input component
  54744. */
  54745. readonly right: NodeMaterialConnectionPoint;
  54746. /**
  54747. * Gets the output component
  54748. */
  54749. readonly output: NodeMaterialConnectionPoint;
  54750. protected _buildBlock(state: NodeMaterialBuildState): this;
  54751. }
  54752. }
  54753. declare module BABYLON {
  54754. /**
  54755. * Block used to subtract 2 vectors
  54756. */
  54757. export class SubtractBlock extends NodeMaterialBlock {
  54758. /**
  54759. * Creates a new SubtractBlock
  54760. * @param name defines the block name
  54761. */
  54762. constructor(name: string);
  54763. /**
  54764. * Gets the current class name
  54765. * @returns the class name
  54766. */
  54767. getClassName(): string;
  54768. /**
  54769. * Gets the left operand input component
  54770. */
  54771. readonly left: NodeMaterialConnectionPoint;
  54772. /**
  54773. * Gets the right operand input component
  54774. */
  54775. readonly right: NodeMaterialConnectionPoint;
  54776. /**
  54777. * Gets the output component
  54778. */
  54779. readonly output: NodeMaterialConnectionPoint;
  54780. protected _buildBlock(state: NodeMaterialBuildState): this;
  54781. }
  54782. }
  54783. declare module BABYLON {
  54784. /**
  54785. * Block used to step a value
  54786. */
  54787. export class StepBlock extends NodeMaterialBlock {
  54788. /**
  54789. * Creates a new AddBlock
  54790. * @param name defines the block name
  54791. */
  54792. constructor(name: string);
  54793. /**
  54794. * Gets the current class name
  54795. * @returns the class name
  54796. */
  54797. getClassName(): string;
  54798. /**
  54799. * Gets the value operand input component
  54800. */
  54801. readonly value: NodeMaterialConnectionPoint;
  54802. /**
  54803. * Gets the edge operand input component
  54804. */
  54805. readonly edge: NodeMaterialConnectionPoint;
  54806. /**
  54807. * Gets the output component
  54808. */
  54809. readonly output: NodeMaterialConnectionPoint;
  54810. protected _buildBlock(state: NodeMaterialBuildState): this;
  54811. }
  54812. }
  54813. declare module BABYLON {
  54814. /**
  54815. * Block used to get the opposite (1 - x) of a value
  54816. */
  54817. export class OneMinusBlock extends NodeMaterialBlock {
  54818. /**
  54819. * Creates a new OneMinusBlock
  54820. * @param name defines the block name
  54821. */
  54822. constructor(name: string);
  54823. /**
  54824. * Gets the current class name
  54825. * @returns the class name
  54826. */
  54827. getClassName(): string;
  54828. /**
  54829. * Gets the input component
  54830. */
  54831. readonly input: NodeMaterialConnectionPoint;
  54832. /**
  54833. * Gets the output component
  54834. */
  54835. readonly output: NodeMaterialConnectionPoint;
  54836. protected _buildBlock(state: NodeMaterialBuildState): this;
  54837. }
  54838. }
  54839. declare module BABYLON {
  54840. /**
  54841. * Block used to get the view direction
  54842. */
  54843. export class ViewDirectionBlock extends NodeMaterialBlock {
  54844. /**
  54845. * Creates a new ViewDirectionBlock
  54846. * @param name defines the block name
  54847. */
  54848. constructor(name: string);
  54849. /**
  54850. * Gets the current class name
  54851. * @returns the class name
  54852. */
  54853. getClassName(): string;
  54854. /**
  54855. * Gets the world position component
  54856. */
  54857. readonly worldPosition: NodeMaterialConnectionPoint;
  54858. /**
  54859. * Gets the camera position component
  54860. */
  54861. readonly cameraPosition: NodeMaterialConnectionPoint;
  54862. /**
  54863. * Gets the output component
  54864. */
  54865. readonly output: NodeMaterialConnectionPoint;
  54866. autoConfigure(material: NodeMaterial): void;
  54867. protected _buildBlock(state: NodeMaterialBuildState): this;
  54868. }
  54869. }
  54870. declare module BABYLON {
  54871. /**
  54872. * Block used to compute fresnel value
  54873. */
  54874. export class FresnelBlock extends NodeMaterialBlock {
  54875. /**
  54876. * Create a new FresnelBlock
  54877. * @param name defines the block name
  54878. */
  54879. constructor(name: string);
  54880. /**
  54881. * Gets the current class name
  54882. * @returns the class name
  54883. */
  54884. getClassName(): string;
  54885. /**
  54886. * Gets the world normal input component
  54887. */
  54888. readonly worldNormal: NodeMaterialConnectionPoint;
  54889. /**
  54890. * Gets the view direction input component
  54891. */
  54892. readonly viewDirection: NodeMaterialConnectionPoint;
  54893. /**
  54894. * Gets the bias input component
  54895. */
  54896. readonly bias: NodeMaterialConnectionPoint;
  54897. /**
  54898. * Gets the camera (or eye) position component
  54899. */
  54900. readonly power: NodeMaterialConnectionPoint;
  54901. /**
  54902. * Gets the fresnel output component
  54903. */
  54904. readonly fresnel: NodeMaterialConnectionPoint;
  54905. autoConfigure(material: NodeMaterial): void;
  54906. protected _buildBlock(state: NodeMaterialBuildState): this;
  54907. }
  54908. }
  54909. declare module BABYLON {
  54910. /**
  54911. * Block used to get the max of 2 values
  54912. */
  54913. export class MaxBlock extends NodeMaterialBlock {
  54914. /**
  54915. * Creates a new MaxBlock
  54916. * @param name defines the block name
  54917. */
  54918. constructor(name: string);
  54919. /**
  54920. * Gets the current class name
  54921. * @returns the class name
  54922. */
  54923. getClassName(): string;
  54924. /**
  54925. * Gets the left operand input component
  54926. */
  54927. readonly left: NodeMaterialConnectionPoint;
  54928. /**
  54929. * Gets the right operand input component
  54930. */
  54931. readonly right: NodeMaterialConnectionPoint;
  54932. /**
  54933. * Gets the output component
  54934. */
  54935. readonly output: NodeMaterialConnectionPoint;
  54936. protected _buildBlock(state: NodeMaterialBuildState): this;
  54937. }
  54938. }
  54939. declare module BABYLON {
  54940. /**
  54941. * Block used to get the min of 2 values
  54942. */
  54943. export class MinBlock extends NodeMaterialBlock {
  54944. /**
  54945. * Creates a new MinBlock
  54946. * @param name defines the block name
  54947. */
  54948. constructor(name: string);
  54949. /**
  54950. * Gets the current class name
  54951. * @returns the class name
  54952. */
  54953. getClassName(): string;
  54954. /**
  54955. * Gets the left operand input component
  54956. */
  54957. readonly left: NodeMaterialConnectionPoint;
  54958. /**
  54959. * Gets the right operand input component
  54960. */
  54961. readonly right: NodeMaterialConnectionPoint;
  54962. /**
  54963. * Gets the output component
  54964. */
  54965. readonly output: NodeMaterialConnectionPoint;
  54966. protected _buildBlock(state: NodeMaterialBuildState): this;
  54967. }
  54968. }
  54969. declare module BABYLON {
  54970. /**
  54971. * Block used to get the distance between 2 values
  54972. */
  54973. export class DistanceBlock extends NodeMaterialBlock {
  54974. /**
  54975. * Creates a new DistanceBlock
  54976. * @param name defines the block name
  54977. */
  54978. constructor(name: string);
  54979. /**
  54980. * Gets the current class name
  54981. * @returns the class name
  54982. */
  54983. getClassName(): string;
  54984. /**
  54985. * Gets the left operand input component
  54986. */
  54987. readonly left: NodeMaterialConnectionPoint;
  54988. /**
  54989. * Gets the right operand input component
  54990. */
  54991. readonly right: NodeMaterialConnectionPoint;
  54992. /**
  54993. * Gets the output component
  54994. */
  54995. readonly output: NodeMaterialConnectionPoint;
  54996. protected _buildBlock(state: NodeMaterialBuildState): this;
  54997. }
  54998. }
  54999. declare module BABYLON {
  55000. /**
  55001. * Block used to get the length of a vector
  55002. */
  55003. export class LengthBlock extends NodeMaterialBlock {
  55004. /**
  55005. * Creates a new LengthBlock
  55006. * @param name defines the block name
  55007. */
  55008. constructor(name: string);
  55009. /**
  55010. * Gets the current class name
  55011. * @returns the class name
  55012. */
  55013. getClassName(): string;
  55014. /**
  55015. * Gets the value input component
  55016. */
  55017. readonly value: NodeMaterialConnectionPoint;
  55018. /**
  55019. * Gets the output component
  55020. */
  55021. readonly output: NodeMaterialConnectionPoint;
  55022. protected _buildBlock(state: NodeMaterialBuildState): this;
  55023. }
  55024. }
  55025. declare module BABYLON {
  55026. /**
  55027. * Block used to get negative version of a value (i.e. x * -1)
  55028. */
  55029. export class NegateBlock extends NodeMaterialBlock {
  55030. /**
  55031. * Creates a new NegateBlock
  55032. * @param name defines the block name
  55033. */
  55034. constructor(name: string);
  55035. /**
  55036. * Gets the current class name
  55037. * @returns the class name
  55038. */
  55039. getClassName(): string;
  55040. /**
  55041. * Gets the value input component
  55042. */
  55043. readonly value: NodeMaterialConnectionPoint;
  55044. /**
  55045. * Gets the output component
  55046. */
  55047. readonly output: NodeMaterialConnectionPoint;
  55048. protected _buildBlock(state: NodeMaterialBuildState): this;
  55049. }
  55050. }
  55051. declare module BABYLON {
  55052. /**
  55053. * Block used to get the value of the first parameter raised to the power of the second
  55054. */
  55055. export class PowBlock extends NodeMaterialBlock {
  55056. /**
  55057. * Creates a new PowBlock
  55058. * @param name defines the block name
  55059. */
  55060. constructor(name: string);
  55061. /**
  55062. * Gets the current class name
  55063. * @returns the class name
  55064. */
  55065. getClassName(): string;
  55066. /**
  55067. * Gets the value operand input component
  55068. */
  55069. readonly value: NodeMaterialConnectionPoint;
  55070. /**
  55071. * Gets the power operand input component
  55072. */
  55073. readonly power: NodeMaterialConnectionPoint;
  55074. /**
  55075. * Gets the output component
  55076. */
  55077. readonly output: NodeMaterialConnectionPoint;
  55078. protected _buildBlock(state: NodeMaterialBuildState): this;
  55079. }
  55080. }
  55081. declare module BABYLON {
  55082. /**
  55083. * Block used to get a random number
  55084. */
  55085. export class RandomNumberBlock extends NodeMaterialBlock {
  55086. /**
  55087. * Creates a new RandomNumberBlock
  55088. * @param name defines the block name
  55089. */
  55090. constructor(name: string);
  55091. /**
  55092. * Gets the current class name
  55093. * @returns the class name
  55094. */
  55095. getClassName(): string;
  55096. /**
  55097. * Gets the seed input component
  55098. */
  55099. readonly seed: NodeMaterialConnectionPoint;
  55100. /**
  55101. * Gets the output component
  55102. */
  55103. readonly output: NodeMaterialConnectionPoint;
  55104. protected _buildBlock(state: NodeMaterialBuildState): this;
  55105. }
  55106. }
  55107. declare module BABYLON {
  55108. /**
  55109. * Effect Render Options
  55110. */
  55111. export interface IEffectRendererOptions {
  55112. /**
  55113. * Defines the vertices positions.
  55114. */
  55115. positions?: number[];
  55116. /**
  55117. * Defines the indices.
  55118. */
  55119. indices?: number[];
  55120. }
  55121. /**
  55122. * Helper class to render one or more effects
  55123. */
  55124. export class EffectRenderer {
  55125. private engine;
  55126. private static _DefaultOptions;
  55127. private _vertexBuffers;
  55128. private _indexBuffer;
  55129. private _ringBufferIndex;
  55130. private _ringScreenBuffer;
  55131. private _fullscreenViewport;
  55132. private _getNextFrameBuffer;
  55133. /**
  55134. * Creates an effect renderer
  55135. * @param engine the engine to use for rendering
  55136. * @param options defines the options of the effect renderer
  55137. */
  55138. constructor(engine: Engine, options?: IEffectRendererOptions);
  55139. /**
  55140. * Sets the current viewport in normalized coordinates 0-1
  55141. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55142. */
  55143. setViewport(viewport?: Viewport): void;
  55144. /**
  55145. * Binds the embedded attributes buffer to the effect.
  55146. * @param effect Defines the effect to bind the attributes for
  55147. */
  55148. bindBuffers(effect: Effect): void;
  55149. /**
  55150. * Sets the current effect wrapper to use during draw.
  55151. * The effect needs to be ready before calling this api.
  55152. * This also sets the default full screen position attribute.
  55153. * @param effectWrapper Defines the effect to draw with
  55154. */
  55155. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55156. /**
  55157. * Draws a full screen quad.
  55158. */
  55159. draw(): void;
  55160. /**
  55161. * renders one or more effects to a specified texture
  55162. * @param effectWrappers list of effects to renderer
  55163. * @param outputTexture texture to draw to, if null it will render to the screen
  55164. */
  55165. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55166. /**
  55167. * Disposes of the effect renderer
  55168. */
  55169. dispose(): void;
  55170. }
  55171. /**
  55172. * Options to create an EffectWrapper
  55173. */
  55174. interface EffectWrapperCreationOptions {
  55175. /**
  55176. * Engine to use to create the effect
  55177. */
  55178. engine: Engine;
  55179. /**
  55180. * Fragment shader for the effect
  55181. */
  55182. fragmentShader: string;
  55183. /**
  55184. * Vertex shader for the effect
  55185. */
  55186. vertexShader?: string;
  55187. /**
  55188. * Attributes to use in the shader
  55189. */
  55190. attributeNames?: Array<string>;
  55191. /**
  55192. * Uniforms to use in the shader
  55193. */
  55194. uniformNames?: Array<string>;
  55195. /**
  55196. * Texture sampler names to use in the shader
  55197. */
  55198. samplerNames?: Array<string>;
  55199. /**
  55200. * The friendly name of the effect displayed in Spector.
  55201. */
  55202. name?: string;
  55203. }
  55204. /**
  55205. * Wraps an effect to be used for rendering
  55206. */
  55207. export class EffectWrapper {
  55208. /**
  55209. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55210. */
  55211. onApplyObservable: Observable<{}>;
  55212. /**
  55213. * The underlying effect
  55214. */
  55215. effect: Effect;
  55216. /**
  55217. * Creates an effect to be renderer
  55218. * @param creationOptions options to create the effect
  55219. */
  55220. constructor(creationOptions: EffectWrapperCreationOptions);
  55221. /**
  55222. * Disposes of the effect wrapper
  55223. */
  55224. dispose(): void;
  55225. }
  55226. }
  55227. declare module BABYLON {
  55228. /**
  55229. * Helper class to push actions to a pool of workers.
  55230. */
  55231. export class WorkerPool implements IDisposable {
  55232. private _workerInfos;
  55233. private _pendingActions;
  55234. /**
  55235. * Constructor
  55236. * @param workers Array of workers to use for actions
  55237. */
  55238. constructor(workers: Array<Worker>);
  55239. /**
  55240. * Terminates all workers and clears any pending actions.
  55241. */
  55242. dispose(): void;
  55243. /**
  55244. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55245. * pended until a worker has completed its action.
  55246. * @param action The action to perform. Call onComplete when the action is complete.
  55247. */
  55248. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55249. private _execute;
  55250. }
  55251. }
  55252. declare module BABYLON {
  55253. /**
  55254. * Configuration for Draco compression
  55255. */
  55256. export interface IDracoCompressionConfiguration {
  55257. /**
  55258. * Configuration for the decoder.
  55259. */
  55260. decoder: {
  55261. /**
  55262. * The url to the WebAssembly module.
  55263. */
  55264. wasmUrl?: string;
  55265. /**
  55266. * The url to the WebAssembly binary.
  55267. */
  55268. wasmBinaryUrl?: string;
  55269. /**
  55270. * The url to the fallback JavaScript module.
  55271. */
  55272. fallbackUrl?: string;
  55273. };
  55274. }
  55275. /**
  55276. * Draco compression (https://google.github.io/draco/)
  55277. *
  55278. * This class wraps the Draco module.
  55279. *
  55280. * **Encoder**
  55281. *
  55282. * The encoder is not currently implemented.
  55283. *
  55284. * **Decoder**
  55285. *
  55286. * 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.
  55287. *
  55288. * To update the configuration, use the following code:
  55289. * ```javascript
  55290. * DracoCompression.Configuration = {
  55291. * decoder: {
  55292. * wasmUrl: "<url to the WebAssembly library>",
  55293. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55294. * fallbackUrl: "<url to the fallback JavaScript library>",
  55295. * }
  55296. * };
  55297. * ```
  55298. *
  55299. * 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.
  55300. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55301. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55302. *
  55303. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55304. * ```javascript
  55305. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55306. * ```
  55307. *
  55308. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55309. */
  55310. export class DracoCompression implements IDisposable {
  55311. private _workerPoolPromise?;
  55312. private _decoderModulePromise?;
  55313. /**
  55314. * The configuration. Defaults to the following urls:
  55315. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55316. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55317. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55318. */
  55319. static Configuration: IDracoCompressionConfiguration;
  55320. /**
  55321. * Returns true if the decoder configuration is available.
  55322. */
  55323. static readonly DecoderAvailable: boolean;
  55324. /**
  55325. * Default number of workers to create when creating the draco compression object.
  55326. */
  55327. static DefaultNumWorkers: number;
  55328. private static GetDefaultNumWorkers;
  55329. private static _Default;
  55330. /**
  55331. * Default instance for the draco compression object.
  55332. */
  55333. static readonly Default: DracoCompression;
  55334. /**
  55335. * Constructor
  55336. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55337. */
  55338. constructor(numWorkers?: number);
  55339. /**
  55340. * Stop all async operations and release resources.
  55341. */
  55342. dispose(): void;
  55343. /**
  55344. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55345. * @returns a promise that resolves when ready
  55346. */
  55347. whenReadyAsync(): Promise<void>;
  55348. /**
  55349. * Decode Draco compressed mesh data to vertex data.
  55350. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55351. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55352. * @returns A promise that resolves with the decoded vertex data
  55353. */
  55354. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55355. [kind: string]: number;
  55356. }): Promise<VertexData>;
  55357. }
  55358. }
  55359. declare module BABYLON {
  55360. /**
  55361. * Class for building Constructive Solid Geometry
  55362. */
  55363. export class CSG {
  55364. private polygons;
  55365. /**
  55366. * The world matrix
  55367. */
  55368. matrix: Matrix;
  55369. /**
  55370. * Stores the position
  55371. */
  55372. position: Vector3;
  55373. /**
  55374. * Stores the rotation
  55375. */
  55376. rotation: Vector3;
  55377. /**
  55378. * Stores the rotation quaternion
  55379. */
  55380. rotationQuaternion: Nullable<Quaternion>;
  55381. /**
  55382. * Stores the scaling vector
  55383. */
  55384. scaling: Vector3;
  55385. /**
  55386. * Convert the Mesh to CSG
  55387. * @param mesh The Mesh to convert to CSG
  55388. * @returns A new CSG from the Mesh
  55389. */
  55390. static FromMesh(mesh: Mesh): CSG;
  55391. /**
  55392. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55393. * @param polygons Polygons used to construct a CSG solid
  55394. */
  55395. private static FromPolygons;
  55396. /**
  55397. * Clones, or makes a deep copy, of the CSG
  55398. * @returns A new CSG
  55399. */
  55400. clone(): CSG;
  55401. /**
  55402. * Unions this CSG with another CSG
  55403. * @param csg The CSG to union against this CSG
  55404. * @returns The unioned CSG
  55405. */
  55406. union(csg: CSG): CSG;
  55407. /**
  55408. * Unions this CSG with another CSG in place
  55409. * @param csg The CSG to union against this CSG
  55410. */
  55411. unionInPlace(csg: CSG): void;
  55412. /**
  55413. * Subtracts this CSG with another CSG
  55414. * @param csg The CSG to subtract against this CSG
  55415. * @returns A new CSG
  55416. */
  55417. subtract(csg: CSG): CSG;
  55418. /**
  55419. * Subtracts this CSG with another CSG in place
  55420. * @param csg The CSG to subtact against this CSG
  55421. */
  55422. subtractInPlace(csg: CSG): void;
  55423. /**
  55424. * Intersect this CSG with another CSG
  55425. * @param csg The CSG to intersect against this CSG
  55426. * @returns A new CSG
  55427. */
  55428. intersect(csg: CSG): CSG;
  55429. /**
  55430. * Intersects this CSG with another CSG in place
  55431. * @param csg The CSG to intersect against this CSG
  55432. */
  55433. intersectInPlace(csg: CSG): void;
  55434. /**
  55435. * Return a new CSG solid with solid and empty space switched. This solid is
  55436. * not modified.
  55437. * @returns A new CSG solid with solid and empty space switched
  55438. */
  55439. inverse(): CSG;
  55440. /**
  55441. * Inverses the CSG in place
  55442. */
  55443. inverseInPlace(): void;
  55444. /**
  55445. * This is used to keep meshes transformations so they can be restored
  55446. * when we build back a Babylon Mesh
  55447. * NB : All CSG operations are performed in world coordinates
  55448. * @param csg The CSG to copy the transform attributes from
  55449. * @returns This CSG
  55450. */
  55451. copyTransformAttributes(csg: CSG): CSG;
  55452. /**
  55453. * Build Raw mesh from CSG
  55454. * Coordinates here are in world space
  55455. * @param name The name of the mesh geometry
  55456. * @param scene The Scene
  55457. * @param keepSubMeshes Specifies if the submeshes should be kept
  55458. * @returns A new Mesh
  55459. */
  55460. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55461. /**
  55462. * Build Mesh from CSG taking material and transforms into account
  55463. * @param name The name of the Mesh
  55464. * @param material The material of the Mesh
  55465. * @param scene The Scene
  55466. * @param keepSubMeshes Specifies if submeshes should be kept
  55467. * @returns The new Mesh
  55468. */
  55469. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55470. }
  55471. }
  55472. declare module BABYLON {
  55473. /**
  55474. * Class used to create a trail following a mesh
  55475. */
  55476. export class TrailMesh extends Mesh {
  55477. private _generator;
  55478. private _autoStart;
  55479. private _running;
  55480. private _diameter;
  55481. private _length;
  55482. private _sectionPolygonPointsCount;
  55483. private _sectionVectors;
  55484. private _sectionNormalVectors;
  55485. private _beforeRenderObserver;
  55486. /**
  55487. * @constructor
  55488. * @param name The value used by scene.getMeshByName() to do a lookup.
  55489. * @param generator The mesh to generate a trail.
  55490. * @param scene The scene to add this mesh to.
  55491. * @param diameter Diameter of trailing mesh. Default is 1.
  55492. * @param length Length of trailing mesh. Default is 60.
  55493. * @param autoStart Automatically start trailing mesh. Default true.
  55494. */
  55495. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55496. /**
  55497. * "TrailMesh"
  55498. * @returns "TrailMesh"
  55499. */
  55500. getClassName(): string;
  55501. private _createMesh;
  55502. /**
  55503. * Start trailing mesh.
  55504. */
  55505. start(): void;
  55506. /**
  55507. * Stop trailing mesh.
  55508. */
  55509. stop(): void;
  55510. /**
  55511. * Update trailing mesh geometry.
  55512. */
  55513. update(): void;
  55514. /**
  55515. * Returns a new TrailMesh object.
  55516. * @param name is a string, the name given to the new mesh
  55517. * @param newGenerator use new generator object for cloned trail mesh
  55518. * @returns a new mesh
  55519. */
  55520. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55521. /**
  55522. * Serializes this trail mesh
  55523. * @param serializationObject object to write serialization to
  55524. */
  55525. serialize(serializationObject: any): void;
  55526. /**
  55527. * Parses a serialized trail mesh
  55528. * @param parsedMesh the serialized mesh
  55529. * @param scene the scene to create the trail mesh in
  55530. * @returns the created trail mesh
  55531. */
  55532. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55533. }
  55534. }
  55535. declare module BABYLON {
  55536. /**
  55537. * Class containing static functions to help procedurally build meshes
  55538. */
  55539. export class TiledBoxBuilder {
  55540. /**
  55541. * Creates a box mesh
  55542. * 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)
  55543. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55544. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55545. * * 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
  55546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55547. * @param name defines the name of the mesh
  55548. * @param options defines the options used to create the mesh
  55549. * @param scene defines the hosting scene
  55550. * @returns the box mesh
  55551. */
  55552. static CreateTiledBox(name: string, options: {
  55553. pattern?: number;
  55554. width?: number;
  55555. height?: number;
  55556. depth?: number;
  55557. tileSize?: number;
  55558. tileWidth?: number;
  55559. tileHeight?: number;
  55560. alignHorizontal?: number;
  55561. alignVertical?: number;
  55562. faceUV?: Vector4[];
  55563. faceColors?: Color4[];
  55564. sideOrientation?: number;
  55565. updatable?: boolean;
  55566. }, scene?: Nullable<Scene>): Mesh;
  55567. }
  55568. }
  55569. declare module BABYLON {
  55570. /**
  55571. * Class containing static functions to help procedurally build meshes
  55572. */
  55573. export class TorusKnotBuilder {
  55574. /**
  55575. * Creates a torus knot mesh
  55576. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55577. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55578. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55579. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55581. * * 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
  55582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55583. * @param name defines the name of the mesh
  55584. * @param options defines the options used to create the mesh
  55585. * @param scene defines the hosting scene
  55586. * @returns the torus knot mesh
  55587. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55588. */
  55589. static CreateTorusKnot(name: string, options: {
  55590. radius?: number;
  55591. tube?: number;
  55592. radialSegments?: number;
  55593. tubularSegments?: number;
  55594. p?: number;
  55595. q?: number;
  55596. updatable?: boolean;
  55597. sideOrientation?: number;
  55598. frontUVs?: Vector4;
  55599. backUVs?: Vector4;
  55600. }, scene: any): Mesh;
  55601. }
  55602. }
  55603. declare module BABYLON {
  55604. /**
  55605. * Polygon
  55606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55607. */
  55608. export class Polygon {
  55609. /**
  55610. * Creates a rectangle
  55611. * @param xmin bottom X coord
  55612. * @param ymin bottom Y coord
  55613. * @param xmax top X coord
  55614. * @param ymax top Y coord
  55615. * @returns points that make the resulting rectation
  55616. */
  55617. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55618. /**
  55619. * Creates a circle
  55620. * @param radius radius of circle
  55621. * @param cx scale in x
  55622. * @param cy scale in y
  55623. * @param numberOfSides number of sides that make up the circle
  55624. * @returns points that make the resulting circle
  55625. */
  55626. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55627. /**
  55628. * Creates a polygon from input string
  55629. * @param input Input polygon data
  55630. * @returns the parsed points
  55631. */
  55632. static Parse(input: string): Vector2[];
  55633. /**
  55634. * Starts building a polygon from x and y coordinates
  55635. * @param x x coordinate
  55636. * @param y y coordinate
  55637. * @returns the started path2
  55638. */
  55639. static StartingAt(x: number, y: number): Path2;
  55640. }
  55641. /**
  55642. * Builds a polygon
  55643. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55644. */
  55645. export class PolygonMeshBuilder {
  55646. private _points;
  55647. private _outlinepoints;
  55648. private _holes;
  55649. private _name;
  55650. private _scene;
  55651. private _epoints;
  55652. private _eholes;
  55653. private _addToepoint;
  55654. /**
  55655. * Babylon reference to the earcut plugin.
  55656. */
  55657. bjsEarcut: any;
  55658. /**
  55659. * Creates a PolygonMeshBuilder
  55660. * @param name name of the builder
  55661. * @param contours Path of the polygon
  55662. * @param scene scene to add to when creating the mesh
  55663. * @param earcutInjection can be used to inject your own earcut reference
  55664. */
  55665. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55666. /**
  55667. * Adds a whole within the polygon
  55668. * @param hole Array of points defining the hole
  55669. * @returns this
  55670. */
  55671. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55672. /**
  55673. * Creates the polygon
  55674. * @param updatable If the mesh should be updatable
  55675. * @param depth The depth of the mesh created
  55676. * @returns the created mesh
  55677. */
  55678. build(updatable?: boolean, depth?: number): Mesh;
  55679. /**
  55680. * Creates the polygon
  55681. * @param depth The depth of the mesh created
  55682. * @returns the created VertexData
  55683. */
  55684. buildVertexData(depth?: number): VertexData;
  55685. /**
  55686. * Adds a side to the polygon
  55687. * @param positions points that make the polygon
  55688. * @param normals normals of the polygon
  55689. * @param uvs uvs of the polygon
  55690. * @param indices indices of the polygon
  55691. * @param bounds bounds of the polygon
  55692. * @param points points of the polygon
  55693. * @param depth depth of the polygon
  55694. * @param flip flip of the polygon
  55695. */
  55696. private addSide;
  55697. }
  55698. }
  55699. declare module BABYLON {
  55700. /**
  55701. * Class containing static functions to help procedurally build meshes
  55702. */
  55703. export class PolygonBuilder {
  55704. /**
  55705. * Creates a polygon mesh
  55706. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55707. * * 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
  55708. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55710. * * 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)
  55711. * * Remember you can only change the shape positions, not their number when updating a polygon
  55712. * @param name defines the name of the mesh
  55713. * @param options defines the options used to create the mesh
  55714. * @param scene defines the hosting scene
  55715. * @param earcutInjection can be used to inject your own earcut reference
  55716. * @returns the polygon mesh
  55717. */
  55718. static CreatePolygon(name: string, options: {
  55719. shape: Vector3[];
  55720. holes?: Vector3[][];
  55721. depth?: number;
  55722. faceUV?: Vector4[];
  55723. faceColors?: Color4[];
  55724. updatable?: boolean;
  55725. sideOrientation?: number;
  55726. frontUVs?: Vector4;
  55727. backUVs?: Vector4;
  55728. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55729. /**
  55730. * Creates an extruded polygon mesh, with depth in the Y direction.
  55731. * * 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)
  55732. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55733. * @param name defines the name of the mesh
  55734. * @param options defines the options used to create the mesh
  55735. * @param scene defines the hosting scene
  55736. * @param earcutInjection can be used to inject your own earcut reference
  55737. * @returns the polygon mesh
  55738. */
  55739. static ExtrudePolygon(name: string, options: {
  55740. shape: Vector3[];
  55741. holes?: Vector3[][];
  55742. depth?: number;
  55743. faceUV?: Vector4[];
  55744. faceColors?: Color4[];
  55745. updatable?: boolean;
  55746. sideOrientation?: number;
  55747. frontUVs?: Vector4;
  55748. backUVs?: Vector4;
  55749. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55750. }
  55751. }
  55752. declare module BABYLON {
  55753. /**
  55754. * Class containing static functions to help procedurally build meshes
  55755. */
  55756. export class LatheBuilder {
  55757. /**
  55758. * Creates lathe mesh.
  55759. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55760. * * 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
  55761. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55762. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55763. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55764. * * 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
  55765. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55766. * * 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
  55767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55768. * * 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
  55769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55771. * @param name defines the name of the mesh
  55772. * @param options defines the options used to create the mesh
  55773. * @param scene defines the hosting scene
  55774. * @returns the lathe mesh
  55775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55776. */
  55777. static CreateLathe(name: string, options: {
  55778. shape: Vector3[];
  55779. radius?: number;
  55780. tessellation?: number;
  55781. clip?: number;
  55782. arc?: number;
  55783. closed?: boolean;
  55784. updatable?: boolean;
  55785. sideOrientation?: number;
  55786. frontUVs?: Vector4;
  55787. backUVs?: Vector4;
  55788. cap?: number;
  55789. invertUV?: boolean;
  55790. }, scene?: Nullable<Scene>): Mesh;
  55791. }
  55792. }
  55793. declare module BABYLON {
  55794. /**
  55795. * Class containing static functions to help procedurally build meshes
  55796. */
  55797. export class TiledPlaneBuilder {
  55798. /**
  55799. * Creates a tiled plane mesh
  55800. * * The parameter `pattern` will, depending on value, do nothing or
  55801. * * * flip (reflect about central vertical) alternate tiles across and up
  55802. * * * flip every tile on alternate rows
  55803. * * * rotate (180 degs) alternate tiles across and up
  55804. * * * rotate every tile on alternate rows
  55805. * * * flip and rotate alternate tiles across and up
  55806. * * * flip and rotate every tile on alternate rows
  55807. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55808. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55809. * * 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
  55810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55811. * * 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)
  55812. * * 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)
  55813. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55814. * @param name defines the name of the mesh
  55815. * @param options defines the options used to create the mesh
  55816. * @param scene defines the hosting scene
  55817. * @returns the box mesh
  55818. */
  55819. static CreateTiledPlane(name: string, options: {
  55820. pattern?: number;
  55821. tileSize?: number;
  55822. tileWidth?: number;
  55823. tileHeight?: number;
  55824. size?: number;
  55825. width?: number;
  55826. height?: number;
  55827. alignHorizontal?: number;
  55828. alignVertical?: number;
  55829. sideOrientation?: number;
  55830. frontUVs?: Vector4;
  55831. backUVs?: Vector4;
  55832. updatable?: boolean;
  55833. }, scene?: Nullable<Scene>): Mesh;
  55834. }
  55835. }
  55836. declare module BABYLON {
  55837. /**
  55838. * Class containing static functions to help procedurally build meshes
  55839. */
  55840. export class TubeBuilder {
  55841. /**
  55842. * Creates a tube mesh.
  55843. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55844. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55845. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55846. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55847. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55848. * * 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)
  55849. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55850. * * 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
  55851. * * 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
  55852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55853. * * 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
  55854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55856. * @param name defines the name of the mesh
  55857. * @param options defines the options used to create the mesh
  55858. * @param scene defines the hosting scene
  55859. * @returns the tube mesh
  55860. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55861. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55862. */
  55863. static CreateTube(name: string, options: {
  55864. path: Vector3[];
  55865. radius?: number;
  55866. tessellation?: number;
  55867. radiusFunction?: {
  55868. (i: number, distance: number): number;
  55869. };
  55870. cap?: number;
  55871. arc?: number;
  55872. updatable?: boolean;
  55873. sideOrientation?: number;
  55874. frontUVs?: Vector4;
  55875. backUVs?: Vector4;
  55876. instance?: Mesh;
  55877. invertUV?: boolean;
  55878. }, scene?: Nullable<Scene>): Mesh;
  55879. }
  55880. }
  55881. declare module BABYLON {
  55882. /**
  55883. * Class containing static functions to help procedurally build meshes
  55884. */
  55885. export class IcoSphereBuilder {
  55886. /**
  55887. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55888. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55889. * * 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`)
  55890. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55891. * * 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
  55892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55893. * * 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
  55894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55895. * @param name defines the name of the mesh
  55896. * @param options defines the options used to create the mesh
  55897. * @param scene defines the hosting scene
  55898. * @returns the icosahedron mesh
  55899. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55900. */
  55901. static CreateIcoSphere(name: string, options: {
  55902. radius?: number;
  55903. radiusX?: number;
  55904. radiusY?: number;
  55905. radiusZ?: number;
  55906. flat?: boolean;
  55907. subdivisions?: number;
  55908. sideOrientation?: number;
  55909. frontUVs?: Vector4;
  55910. backUVs?: Vector4;
  55911. updatable?: boolean;
  55912. }, scene?: Nullable<Scene>): Mesh;
  55913. }
  55914. }
  55915. declare module BABYLON {
  55916. /**
  55917. * Class containing static functions to help procedurally build meshes
  55918. */
  55919. export class DecalBuilder {
  55920. /**
  55921. * Creates a decal mesh.
  55922. * 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
  55923. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55924. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55925. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55926. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55927. * @param name defines the name of the mesh
  55928. * @param sourceMesh defines the mesh where the decal must be applied
  55929. * @param options defines the options used to create the mesh
  55930. * @param scene defines the hosting scene
  55931. * @returns the decal mesh
  55932. * @see https://doc.babylonjs.com/how_to/decals
  55933. */
  55934. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55935. position?: Vector3;
  55936. normal?: Vector3;
  55937. size?: Vector3;
  55938. angle?: number;
  55939. }): Mesh;
  55940. }
  55941. }
  55942. declare module BABYLON {
  55943. /**
  55944. * Class containing static functions to help procedurally build meshes
  55945. */
  55946. export class MeshBuilder {
  55947. /**
  55948. * Creates a box mesh
  55949. * * The parameter `size` sets the size (float) of each box side (default 1)
  55950. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55951. * * 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)
  55952. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55954. * * 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
  55955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55956. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55957. * @param name defines the name of the mesh
  55958. * @param options defines the options used to create the mesh
  55959. * @param scene defines the hosting scene
  55960. * @returns the box mesh
  55961. */
  55962. static CreateBox(name: string, options: {
  55963. size?: number;
  55964. width?: number;
  55965. height?: number;
  55966. depth?: number;
  55967. faceUV?: Vector4[];
  55968. faceColors?: Color4[];
  55969. sideOrientation?: number;
  55970. frontUVs?: Vector4;
  55971. backUVs?: Vector4;
  55972. updatable?: boolean;
  55973. }, scene?: Nullable<Scene>): Mesh;
  55974. /**
  55975. * Creates a tiled box mesh
  55976. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55978. * @param name defines the name of the mesh
  55979. * @param options defines the options used to create the mesh
  55980. * @param scene defines the hosting scene
  55981. * @returns the tiled box mesh
  55982. */
  55983. static CreateTiledBox(name: string, options: {
  55984. pattern?: number;
  55985. size?: number;
  55986. width?: number;
  55987. height?: number;
  55988. depth: number;
  55989. tileSize?: number;
  55990. tileWidth?: number;
  55991. tileHeight?: number;
  55992. faceUV?: Vector4[];
  55993. faceColors?: Color4[];
  55994. alignHorizontal?: number;
  55995. alignVertical?: number;
  55996. sideOrientation?: number;
  55997. updatable?: boolean;
  55998. }, scene?: Nullable<Scene>): Mesh;
  55999. /**
  56000. * Creates a sphere mesh
  56001. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56002. * * 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`)
  56003. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56004. * * 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
  56005. * * 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)
  56006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56007. * * 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
  56008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56009. * @param name defines the name of the mesh
  56010. * @param options defines the options used to create the mesh
  56011. * @param scene defines the hosting scene
  56012. * @returns the sphere mesh
  56013. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56014. */
  56015. static CreateSphere(name: string, options: {
  56016. segments?: number;
  56017. diameter?: number;
  56018. diameterX?: number;
  56019. diameterY?: number;
  56020. diameterZ?: number;
  56021. arc?: number;
  56022. slice?: number;
  56023. sideOrientation?: number;
  56024. frontUVs?: Vector4;
  56025. backUVs?: Vector4;
  56026. updatable?: boolean;
  56027. }, scene?: Nullable<Scene>): Mesh;
  56028. /**
  56029. * Creates a plane polygonal mesh. By default, this is a disc
  56030. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56031. * * 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
  56032. * * 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
  56033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56034. * * 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
  56035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56036. * @param name defines the name of the mesh
  56037. * @param options defines the options used to create the mesh
  56038. * @param scene defines the hosting scene
  56039. * @returns the plane polygonal mesh
  56040. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56041. */
  56042. static CreateDisc(name: string, options: {
  56043. radius?: number;
  56044. tessellation?: number;
  56045. arc?: number;
  56046. updatable?: boolean;
  56047. sideOrientation?: number;
  56048. frontUVs?: Vector4;
  56049. backUVs?: Vector4;
  56050. }, scene?: Nullable<Scene>): Mesh;
  56051. /**
  56052. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56053. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56054. * * 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`)
  56055. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56056. * * 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
  56057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56058. * * 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
  56059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56060. * @param name defines the name of the mesh
  56061. * @param options defines the options used to create the mesh
  56062. * @param scene defines the hosting scene
  56063. * @returns the icosahedron mesh
  56064. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56065. */
  56066. static CreateIcoSphere(name: string, options: {
  56067. radius?: number;
  56068. radiusX?: number;
  56069. radiusY?: number;
  56070. radiusZ?: number;
  56071. flat?: boolean;
  56072. subdivisions?: number;
  56073. sideOrientation?: number;
  56074. frontUVs?: Vector4;
  56075. backUVs?: Vector4;
  56076. updatable?: boolean;
  56077. }, scene?: Nullable<Scene>): Mesh;
  56078. /**
  56079. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56080. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56081. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56082. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56083. * * 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
  56084. * * 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
  56085. * * 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
  56086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56087. * * 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
  56088. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56089. * * 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
  56090. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56091. * * 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
  56092. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56094. * @param name defines the name of the mesh
  56095. * @param options defines the options used to create the mesh
  56096. * @param scene defines the hosting scene
  56097. * @returns the ribbon mesh
  56098. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56099. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56100. */
  56101. static CreateRibbon(name: string, options: {
  56102. pathArray: Vector3[][];
  56103. closeArray?: boolean;
  56104. closePath?: boolean;
  56105. offset?: number;
  56106. updatable?: boolean;
  56107. sideOrientation?: number;
  56108. frontUVs?: Vector4;
  56109. backUVs?: Vector4;
  56110. instance?: Mesh;
  56111. invertUV?: boolean;
  56112. uvs?: Vector2[];
  56113. colors?: Color4[];
  56114. }, scene?: Nullable<Scene>): Mesh;
  56115. /**
  56116. * Creates a cylinder or a cone mesh
  56117. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56118. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56119. * * 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.
  56120. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56121. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56122. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56123. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56124. * * 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).
  56125. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56126. * * 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).
  56127. * * 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
  56128. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56129. * * 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
  56130. * * 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.
  56131. * * If `enclose` is false, a ring surface is one element.
  56132. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56133. * * 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
  56134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56135. * * 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
  56136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56137. * @param name defines the name of the mesh
  56138. * @param options defines the options used to create the mesh
  56139. * @param scene defines the hosting scene
  56140. * @returns the cylinder mesh
  56141. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56142. */
  56143. static CreateCylinder(name: string, options: {
  56144. height?: number;
  56145. diameterTop?: number;
  56146. diameterBottom?: number;
  56147. diameter?: number;
  56148. tessellation?: number;
  56149. subdivisions?: number;
  56150. arc?: number;
  56151. faceColors?: Color4[];
  56152. faceUV?: Vector4[];
  56153. updatable?: boolean;
  56154. hasRings?: boolean;
  56155. enclose?: boolean;
  56156. cap?: number;
  56157. sideOrientation?: number;
  56158. frontUVs?: Vector4;
  56159. backUVs?: Vector4;
  56160. }, scene?: Nullable<Scene>): Mesh;
  56161. /**
  56162. * Creates a torus mesh
  56163. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56164. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56165. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56167. * * 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
  56168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56169. * @param name defines the name of the mesh
  56170. * @param options defines the options used to create the mesh
  56171. * @param scene defines the hosting scene
  56172. * @returns the torus mesh
  56173. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56174. */
  56175. static CreateTorus(name: string, options: {
  56176. diameter?: number;
  56177. thickness?: number;
  56178. tessellation?: number;
  56179. updatable?: boolean;
  56180. sideOrientation?: number;
  56181. frontUVs?: Vector4;
  56182. backUVs?: Vector4;
  56183. }, scene?: Nullable<Scene>): Mesh;
  56184. /**
  56185. * Creates a torus knot mesh
  56186. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56187. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56188. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56189. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56191. * * 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
  56192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56193. * @param name defines the name of the mesh
  56194. * @param options defines the options used to create the mesh
  56195. * @param scene defines the hosting scene
  56196. * @returns the torus knot mesh
  56197. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56198. */
  56199. static CreateTorusKnot(name: string, options: {
  56200. radius?: number;
  56201. tube?: number;
  56202. radialSegments?: number;
  56203. tubularSegments?: number;
  56204. p?: number;
  56205. q?: number;
  56206. updatable?: boolean;
  56207. sideOrientation?: number;
  56208. frontUVs?: Vector4;
  56209. backUVs?: Vector4;
  56210. }, scene?: Nullable<Scene>): Mesh;
  56211. /**
  56212. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56213. * * 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
  56214. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56215. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56216. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56217. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56218. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56219. * * 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
  56220. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56223. * @param name defines the name of the new line system
  56224. * @param options defines the options used to create the line system
  56225. * @param scene defines the hosting scene
  56226. * @returns a new line system mesh
  56227. */
  56228. static CreateLineSystem(name: string, options: {
  56229. lines: Vector3[][];
  56230. updatable?: boolean;
  56231. instance?: Nullable<LinesMesh>;
  56232. colors?: Nullable<Color4[][]>;
  56233. useVertexAlpha?: boolean;
  56234. }, scene: Nullable<Scene>): LinesMesh;
  56235. /**
  56236. * Creates a line mesh
  56237. * 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
  56238. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56239. * * The parameter `points` is an array successive Vector3
  56240. * * 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
  56241. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56243. * * When updating an instance, remember that only point positions can change, not the number of points
  56244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56245. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56246. * @param name defines the name of the new line system
  56247. * @param options defines the options used to create the line system
  56248. * @param scene defines the hosting scene
  56249. * @returns a new line mesh
  56250. */
  56251. static CreateLines(name: string, options: {
  56252. points: Vector3[];
  56253. updatable?: boolean;
  56254. instance?: Nullable<LinesMesh>;
  56255. colors?: Color4[];
  56256. useVertexAlpha?: boolean;
  56257. }, scene?: Nullable<Scene>): LinesMesh;
  56258. /**
  56259. * Creates a dashed line mesh
  56260. * * 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
  56261. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56262. * * The parameter `points` is an array successive Vector3
  56263. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56264. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56265. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56266. * * 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
  56267. * * When updating an instance, remember that only point positions can change, not the number of points
  56268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56269. * @param name defines the name of the mesh
  56270. * @param options defines the options used to create the mesh
  56271. * @param scene defines the hosting scene
  56272. * @returns the dashed line mesh
  56273. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56274. */
  56275. static CreateDashedLines(name: string, options: {
  56276. points: Vector3[];
  56277. dashSize?: number;
  56278. gapSize?: number;
  56279. dashNb?: number;
  56280. updatable?: boolean;
  56281. instance?: LinesMesh;
  56282. }, scene?: Nullable<Scene>): LinesMesh;
  56283. /**
  56284. * 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.
  56285. * * 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.
  56286. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56287. * * 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.
  56288. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56289. * * 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
  56290. * * 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
  56291. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56293. * * 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
  56294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56296. * @param name defines the name of the mesh
  56297. * @param options defines the options used to create the mesh
  56298. * @param scene defines the hosting scene
  56299. * @returns the extruded shape mesh
  56300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56302. */
  56303. static ExtrudeShape(name: string, options: {
  56304. shape: Vector3[];
  56305. path: Vector3[];
  56306. scale?: number;
  56307. rotation?: number;
  56308. cap?: number;
  56309. updatable?: boolean;
  56310. sideOrientation?: number;
  56311. frontUVs?: Vector4;
  56312. backUVs?: Vector4;
  56313. instance?: Mesh;
  56314. invertUV?: boolean;
  56315. }, scene?: Nullable<Scene>): Mesh;
  56316. /**
  56317. * Creates an custom extruded shape mesh.
  56318. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56319. * * 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.
  56320. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56321. * * 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
  56322. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56323. * * 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
  56324. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56325. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56326. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56327. * * 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
  56328. * * 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
  56329. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56331. * * 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
  56332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56334. * @param name defines the name of the mesh
  56335. * @param options defines the options used to create the mesh
  56336. * @param scene defines the hosting scene
  56337. * @returns the custom extruded shape mesh
  56338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56341. */
  56342. static ExtrudeShapeCustom(name: string, options: {
  56343. shape: Vector3[];
  56344. path: Vector3[];
  56345. scaleFunction?: any;
  56346. rotationFunction?: any;
  56347. ribbonCloseArray?: boolean;
  56348. ribbonClosePath?: boolean;
  56349. cap?: number;
  56350. updatable?: boolean;
  56351. sideOrientation?: number;
  56352. frontUVs?: Vector4;
  56353. backUVs?: Vector4;
  56354. instance?: Mesh;
  56355. invertUV?: boolean;
  56356. }, scene?: Nullable<Scene>): Mesh;
  56357. /**
  56358. * Creates lathe mesh.
  56359. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56360. * * 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
  56361. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56362. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56363. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56364. * * 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
  56365. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56366. * * 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
  56367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56368. * * 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
  56369. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56371. * @param name defines the name of the mesh
  56372. * @param options defines the options used to create the mesh
  56373. * @param scene defines the hosting scene
  56374. * @returns the lathe mesh
  56375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56376. */
  56377. static CreateLathe(name: string, options: {
  56378. shape: Vector3[];
  56379. radius?: number;
  56380. tessellation?: number;
  56381. clip?: number;
  56382. arc?: number;
  56383. closed?: boolean;
  56384. updatable?: boolean;
  56385. sideOrientation?: number;
  56386. frontUVs?: Vector4;
  56387. backUVs?: Vector4;
  56388. cap?: number;
  56389. invertUV?: boolean;
  56390. }, scene?: Nullable<Scene>): Mesh;
  56391. /**
  56392. * Creates a tiled plane mesh
  56393. * * You can set a limited pattern arrangement with the tiles
  56394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56395. * * 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
  56396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56397. * @param name defines the name of the mesh
  56398. * @param options defines the options used to create the mesh
  56399. * @param scene defines the hosting scene
  56400. * @returns the plane mesh
  56401. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56402. */
  56403. static CreateTiledPlane(name: string, options: {
  56404. pattern?: number;
  56405. tileSize?: number;
  56406. tileWidth?: number;
  56407. tileHeight?: number;
  56408. size?: number;
  56409. width?: number;
  56410. height?: number;
  56411. alignHorizontal?: number;
  56412. alignVertical?: number;
  56413. sideOrientation?: number;
  56414. frontUVs?: Vector4;
  56415. backUVs?: Vector4;
  56416. updatable?: boolean;
  56417. }, scene?: Nullable<Scene>): Mesh;
  56418. /**
  56419. * Creates a plane mesh
  56420. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56421. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56422. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56424. * * 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
  56425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56426. * @param name defines the name of the mesh
  56427. * @param options defines the options used to create the mesh
  56428. * @param scene defines the hosting scene
  56429. * @returns the plane mesh
  56430. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56431. */
  56432. static CreatePlane(name: string, options: {
  56433. size?: number;
  56434. width?: number;
  56435. height?: number;
  56436. sideOrientation?: number;
  56437. frontUVs?: Vector4;
  56438. backUVs?: Vector4;
  56439. updatable?: boolean;
  56440. sourcePlane?: Plane;
  56441. }, scene?: Nullable<Scene>): Mesh;
  56442. /**
  56443. * Creates a ground mesh
  56444. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56445. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56447. * @param name defines the name of the mesh
  56448. * @param options defines the options used to create the mesh
  56449. * @param scene defines the hosting scene
  56450. * @returns the ground mesh
  56451. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56452. */
  56453. static CreateGround(name: string, options: {
  56454. width?: number;
  56455. height?: number;
  56456. subdivisions?: number;
  56457. subdivisionsX?: number;
  56458. subdivisionsY?: number;
  56459. updatable?: boolean;
  56460. }, scene?: Nullable<Scene>): Mesh;
  56461. /**
  56462. * Creates a tiled ground mesh
  56463. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56464. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56465. * * 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
  56466. * * 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
  56467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56468. * @param name defines the name of the mesh
  56469. * @param options defines the options used to create the mesh
  56470. * @param scene defines the hosting scene
  56471. * @returns the tiled ground mesh
  56472. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56473. */
  56474. static CreateTiledGround(name: string, options: {
  56475. xmin: number;
  56476. zmin: number;
  56477. xmax: number;
  56478. zmax: number;
  56479. subdivisions?: {
  56480. w: number;
  56481. h: number;
  56482. };
  56483. precision?: {
  56484. w: number;
  56485. h: number;
  56486. };
  56487. updatable?: boolean;
  56488. }, scene?: Nullable<Scene>): Mesh;
  56489. /**
  56490. * Creates a ground mesh from a height map
  56491. * * The parameter `url` sets the URL of the height map image resource.
  56492. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56493. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56494. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56495. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56496. * * 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.
  56497. * * 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).
  56498. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56500. * @param name defines the name of the mesh
  56501. * @param url defines the url to the height map
  56502. * @param options defines the options used to create the mesh
  56503. * @param scene defines the hosting scene
  56504. * @returns the ground mesh
  56505. * @see https://doc.babylonjs.com/babylon101/height_map
  56506. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56507. */
  56508. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56509. width?: number;
  56510. height?: number;
  56511. subdivisions?: number;
  56512. minHeight?: number;
  56513. maxHeight?: number;
  56514. colorFilter?: Color3;
  56515. alphaFilter?: number;
  56516. updatable?: boolean;
  56517. onReady?: (mesh: GroundMesh) => void;
  56518. }, scene?: Nullable<Scene>): GroundMesh;
  56519. /**
  56520. * Creates a polygon mesh
  56521. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56522. * * 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
  56523. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56525. * * 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)
  56526. * * Remember you can only change the shape positions, not their number when updating a polygon
  56527. * @param name defines the name of the mesh
  56528. * @param options defines the options used to create the mesh
  56529. * @param scene defines the hosting scene
  56530. * @param earcutInjection can be used to inject your own earcut reference
  56531. * @returns the polygon mesh
  56532. */
  56533. static CreatePolygon(name: string, options: {
  56534. shape: Vector3[];
  56535. holes?: Vector3[][];
  56536. depth?: number;
  56537. faceUV?: Vector4[];
  56538. faceColors?: Color4[];
  56539. updatable?: boolean;
  56540. sideOrientation?: number;
  56541. frontUVs?: Vector4;
  56542. backUVs?: Vector4;
  56543. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56544. /**
  56545. * Creates an extruded polygon mesh, with depth in the Y direction.
  56546. * * 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)
  56547. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56548. * @param name defines the name of the mesh
  56549. * @param options defines the options used to create the mesh
  56550. * @param scene defines the hosting scene
  56551. * @param earcutInjection can be used to inject your own earcut reference
  56552. * @returns the polygon mesh
  56553. */
  56554. static ExtrudePolygon(name: string, options: {
  56555. shape: Vector3[];
  56556. holes?: Vector3[][];
  56557. depth?: number;
  56558. faceUV?: Vector4[];
  56559. faceColors?: Color4[];
  56560. updatable?: boolean;
  56561. sideOrientation?: number;
  56562. frontUVs?: Vector4;
  56563. backUVs?: Vector4;
  56564. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56565. /**
  56566. * Creates a tube mesh.
  56567. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56568. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56569. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56570. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56571. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56572. * * 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)
  56573. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56574. * * 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
  56575. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56580. * @param name defines the name of the mesh
  56581. * @param options defines the options used to create the mesh
  56582. * @param scene defines the hosting scene
  56583. * @returns the tube mesh
  56584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56585. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56586. */
  56587. static CreateTube(name: string, options: {
  56588. path: Vector3[];
  56589. radius?: number;
  56590. tessellation?: number;
  56591. radiusFunction?: {
  56592. (i: number, distance: number): number;
  56593. };
  56594. cap?: number;
  56595. arc?: number;
  56596. updatable?: boolean;
  56597. sideOrientation?: number;
  56598. frontUVs?: Vector4;
  56599. backUVs?: Vector4;
  56600. instance?: Mesh;
  56601. invertUV?: boolean;
  56602. }, scene?: Nullable<Scene>): Mesh;
  56603. /**
  56604. * Creates a polyhedron mesh
  56605. * * 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
  56606. * * The parameter `size` (positive float, default 1) sets the polygon size
  56607. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56608. * * 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`
  56609. * * 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
  56610. * * 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)`)
  56611. * * 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
  56612. * * 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
  56613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56614. * * 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
  56615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56616. * @param name defines the name of the mesh
  56617. * @param options defines the options used to create the mesh
  56618. * @param scene defines the hosting scene
  56619. * @returns the polyhedron mesh
  56620. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56621. */
  56622. static CreatePolyhedron(name: string, options: {
  56623. type?: number;
  56624. size?: number;
  56625. sizeX?: number;
  56626. sizeY?: number;
  56627. sizeZ?: number;
  56628. custom?: any;
  56629. faceUV?: Vector4[];
  56630. faceColors?: Color4[];
  56631. flat?: boolean;
  56632. updatable?: boolean;
  56633. sideOrientation?: number;
  56634. frontUVs?: Vector4;
  56635. backUVs?: Vector4;
  56636. }, scene?: Nullable<Scene>): Mesh;
  56637. /**
  56638. * Creates a decal mesh.
  56639. * 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
  56640. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56641. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56642. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56643. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56644. * @param name defines the name of the mesh
  56645. * @param sourceMesh defines the mesh where the decal must be applied
  56646. * @param options defines the options used to create the mesh
  56647. * @param scene defines the hosting scene
  56648. * @returns the decal mesh
  56649. * @see https://doc.babylonjs.com/how_to/decals
  56650. */
  56651. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56652. position?: Vector3;
  56653. normal?: Vector3;
  56654. size?: Vector3;
  56655. angle?: number;
  56656. }): Mesh;
  56657. }
  56658. }
  56659. declare module BABYLON {
  56660. /**
  56661. * A simplifier interface for future simplification implementations
  56662. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56663. */
  56664. export interface ISimplifier {
  56665. /**
  56666. * Simplification of a given mesh according to the given settings.
  56667. * Since this requires computation, it is assumed that the function runs async.
  56668. * @param settings The settings of the simplification, including quality and distance
  56669. * @param successCallback A callback that will be called after the mesh was simplified.
  56670. * @param errorCallback in case of an error, this callback will be called. optional.
  56671. */
  56672. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56673. }
  56674. /**
  56675. * Expected simplification settings.
  56676. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56677. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56678. */
  56679. export interface ISimplificationSettings {
  56680. /**
  56681. * Gets or sets the expected quality
  56682. */
  56683. quality: number;
  56684. /**
  56685. * Gets or sets the distance when this optimized version should be used
  56686. */
  56687. distance: number;
  56688. /**
  56689. * Gets an already optimized mesh
  56690. */
  56691. optimizeMesh?: boolean;
  56692. }
  56693. /**
  56694. * Class used to specify simplification options
  56695. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56696. */
  56697. export class SimplificationSettings implements ISimplificationSettings {
  56698. /** expected quality */
  56699. quality: number;
  56700. /** distance when this optimized version should be used */
  56701. distance: number;
  56702. /** already optimized mesh */
  56703. optimizeMesh?: boolean | undefined;
  56704. /**
  56705. * Creates a SimplificationSettings
  56706. * @param quality expected quality
  56707. * @param distance distance when this optimized version should be used
  56708. * @param optimizeMesh already optimized mesh
  56709. */
  56710. constructor(
  56711. /** expected quality */
  56712. quality: number,
  56713. /** distance when this optimized version should be used */
  56714. distance: number,
  56715. /** already optimized mesh */
  56716. optimizeMesh?: boolean | undefined);
  56717. }
  56718. /**
  56719. * Interface used to define a simplification task
  56720. */
  56721. export interface ISimplificationTask {
  56722. /**
  56723. * Array of settings
  56724. */
  56725. settings: Array<ISimplificationSettings>;
  56726. /**
  56727. * Simplification type
  56728. */
  56729. simplificationType: SimplificationType;
  56730. /**
  56731. * Mesh to simplify
  56732. */
  56733. mesh: Mesh;
  56734. /**
  56735. * Callback called on success
  56736. */
  56737. successCallback?: () => void;
  56738. /**
  56739. * Defines if parallel processing can be used
  56740. */
  56741. parallelProcessing: boolean;
  56742. }
  56743. /**
  56744. * Queue used to order the simplification tasks
  56745. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56746. */
  56747. export class SimplificationQueue {
  56748. private _simplificationArray;
  56749. /**
  56750. * Gets a boolean indicating that the process is still running
  56751. */
  56752. running: boolean;
  56753. /**
  56754. * Creates a new queue
  56755. */
  56756. constructor();
  56757. /**
  56758. * Adds a new simplification task
  56759. * @param task defines a task to add
  56760. */
  56761. addTask(task: ISimplificationTask): void;
  56762. /**
  56763. * Execute next task
  56764. */
  56765. executeNext(): void;
  56766. /**
  56767. * Execute a simplification task
  56768. * @param task defines the task to run
  56769. */
  56770. runSimplification(task: ISimplificationTask): void;
  56771. private getSimplifier;
  56772. }
  56773. /**
  56774. * The implemented types of simplification
  56775. * At the moment only Quadratic Error Decimation is implemented
  56776. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56777. */
  56778. export enum SimplificationType {
  56779. /** Quadratic error decimation */
  56780. QUADRATIC = 0
  56781. }
  56782. }
  56783. declare module BABYLON {
  56784. interface Scene {
  56785. /** @hidden (Backing field) */
  56786. _simplificationQueue: SimplificationQueue;
  56787. /**
  56788. * Gets or sets the simplification queue attached to the scene
  56789. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56790. */
  56791. simplificationQueue: SimplificationQueue;
  56792. }
  56793. interface Mesh {
  56794. /**
  56795. * Simplify the mesh according to the given array of settings.
  56796. * Function will return immediately and will simplify async
  56797. * @param settings a collection of simplification settings
  56798. * @param parallelProcessing should all levels calculate parallel or one after the other
  56799. * @param simplificationType the type of simplification to run
  56800. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56801. * @returns the current mesh
  56802. */
  56803. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56804. }
  56805. /**
  56806. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56807. * created in a scene
  56808. */
  56809. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56810. /**
  56811. * The component name helpfull to identify the component in the list of scene components.
  56812. */
  56813. readonly name: string;
  56814. /**
  56815. * The scene the component belongs to.
  56816. */
  56817. scene: Scene;
  56818. /**
  56819. * Creates a new instance of the component for the given scene
  56820. * @param scene Defines the scene to register the component in
  56821. */
  56822. constructor(scene: Scene);
  56823. /**
  56824. * Registers the component in a given scene
  56825. */
  56826. register(): void;
  56827. /**
  56828. * Rebuilds the elements related to this component in case of
  56829. * context lost for instance.
  56830. */
  56831. rebuild(): void;
  56832. /**
  56833. * Disposes the component and the associated ressources
  56834. */
  56835. dispose(): void;
  56836. private _beforeCameraUpdate;
  56837. }
  56838. }
  56839. declare module BABYLON {
  56840. /**
  56841. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56842. */
  56843. export interface INavigationEnginePlugin {
  56844. /**
  56845. * plugin name
  56846. */
  56847. name: string;
  56848. /**
  56849. * Creates a navigation mesh
  56850. * @param meshes array of all the geometry used to compute the navigatio mesh
  56851. * @param parameters bunch of parameters used to filter geometry
  56852. */
  56853. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56854. /**
  56855. * Create a navigation mesh debug mesh
  56856. * @param scene is where the mesh will be added
  56857. * @returns debug display mesh
  56858. */
  56859. createDebugNavMesh(scene: Scene): Mesh;
  56860. /**
  56861. * Get a navigation mesh constrained position, closest to the parameter position
  56862. * @param position world position
  56863. * @returns the closest point to position constrained by the navigation mesh
  56864. */
  56865. getClosestPoint(position: Vector3): Vector3;
  56866. /**
  56867. * Get a navigation mesh constrained position, within a particular radius
  56868. * @param position world position
  56869. * @param maxRadius the maximum distance to the constrained world position
  56870. * @returns the closest point to position constrained by the navigation mesh
  56871. */
  56872. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56873. /**
  56874. * Compute the final position from a segment made of destination-position
  56875. * @param position world position
  56876. * @param destination world position
  56877. * @returns the resulting point along the navmesh
  56878. */
  56879. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56880. /**
  56881. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56882. * @param start world position
  56883. * @param end world position
  56884. * @returns array containing world position composing the path
  56885. */
  56886. computePath(start: Vector3, end: Vector3): Vector3[];
  56887. /**
  56888. * If this plugin is supported
  56889. * @returns true if plugin is supported
  56890. */
  56891. isSupported(): boolean;
  56892. /**
  56893. * Create a new Crowd so you can add agents
  56894. * @param maxAgents the maximum agent count in the crowd
  56895. * @param maxAgentRadius the maximum radius an agent can have
  56896. * @param scene to attach the crowd to
  56897. * @returns the crowd you can add agents to
  56898. */
  56899. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56900. /**
  56901. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56902. * The queries will try to find a solution within those bounds
  56903. * default is (1,1,1)
  56904. * @param extent x,y,z value that define the extent around the queries point of reference
  56905. */
  56906. setDefaultQueryExtent(extent: Vector3): void;
  56907. /**
  56908. * Get the Bounding box extent specified by setDefaultQueryExtent
  56909. * @returns the box extent values
  56910. */
  56911. getDefaultQueryExtent(): Vector3;
  56912. /**
  56913. * Release all resources
  56914. */
  56915. dispose(): void;
  56916. }
  56917. /**
  56918. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56919. */
  56920. export interface ICrowd {
  56921. /**
  56922. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56923. * You can attach anything to that node. The node position is updated in the scene update tick.
  56924. * @param pos world position that will be constrained by the navigation mesh
  56925. * @param parameters agent parameters
  56926. * @param transform hooked to the agent that will be update by the scene
  56927. * @returns agent index
  56928. */
  56929. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56930. /**
  56931. * Returns the agent position in world space
  56932. * @param index agent index returned by addAgent
  56933. * @returns world space position
  56934. */
  56935. getAgentPosition(index: number): Vector3;
  56936. /**
  56937. * Gets the agent velocity in world space
  56938. * @param index agent index returned by addAgent
  56939. * @returns world space velocity
  56940. */
  56941. getAgentVelocity(index: number): Vector3;
  56942. /**
  56943. * remove a particular agent previously created
  56944. * @param index agent index returned by addAgent
  56945. */
  56946. removeAgent(index: number): void;
  56947. /**
  56948. * get the list of all agents attached to this crowd
  56949. * @returns list of agent indices
  56950. */
  56951. getAgents(): number[];
  56952. /**
  56953. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56954. * @param deltaTime in seconds
  56955. */
  56956. update(deltaTime: number): void;
  56957. /**
  56958. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56959. * @param index agent index returned by addAgent
  56960. * @param destination targeted world position
  56961. */
  56962. agentGoto(index: number, destination: Vector3): void;
  56963. /**
  56964. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56965. * The queries will try to find a solution within those bounds
  56966. * default is (1,1,1)
  56967. * @param extent x,y,z value that define the extent around the queries point of reference
  56968. */
  56969. setDefaultQueryExtent(extent: Vector3): void;
  56970. /**
  56971. * Get the Bounding box extent specified by setDefaultQueryExtent
  56972. * @returns the box extent values
  56973. */
  56974. getDefaultQueryExtent(): Vector3;
  56975. /**
  56976. * Release all resources
  56977. */
  56978. dispose(): void;
  56979. }
  56980. /**
  56981. * Configures an agent
  56982. */
  56983. export interface IAgentParameters {
  56984. /**
  56985. * Agent radius. [Limit: >= 0]
  56986. */
  56987. radius: number;
  56988. /**
  56989. * Agent height. [Limit: > 0]
  56990. */
  56991. height: number;
  56992. /**
  56993. * Maximum allowed acceleration. [Limit: >= 0]
  56994. */
  56995. maxAcceleration: number;
  56996. /**
  56997. * Maximum allowed speed. [Limit: >= 0]
  56998. */
  56999. maxSpeed: number;
  57000. /**
  57001. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57002. */
  57003. collisionQueryRange: number;
  57004. /**
  57005. * The path visibility optimization range. [Limit: > 0]
  57006. */
  57007. pathOptimizationRange: number;
  57008. /**
  57009. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57010. */
  57011. separationWeight: number;
  57012. }
  57013. /**
  57014. * Configures the navigation mesh creation
  57015. */
  57016. export interface INavMeshParameters {
  57017. /**
  57018. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57019. */
  57020. cs: number;
  57021. /**
  57022. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57023. */
  57024. ch: number;
  57025. /**
  57026. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57027. */
  57028. walkableSlopeAngle: number;
  57029. /**
  57030. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57031. * be considered walkable. [Limit: >= 3] [Units: vx]
  57032. */
  57033. walkableHeight: number;
  57034. /**
  57035. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57036. */
  57037. walkableClimb: number;
  57038. /**
  57039. * The distance to erode/shrink the walkable area of the heightfield away from
  57040. * obstructions. [Limit: >=0] [Units: vx]
  57041. */
  57042. walkableRadius: number;
  57043. /**
  57044. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57045. */
  57046. maxEdgeLen: number;
  57047. /**
  57048. * The maximum distance a simplfied contour's border edges should deviate
  57049. * the original raw contour. [Limit: >=0] [Units: vx]
  57050. */
  57051. maxSimplificationError: number;
  57052. /**
  57053. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57054. */
  57055. minRegionArea: number;
  57056. /**
  57057. * Any regions with a span count smaller than this value will, if possible,
  57058. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57059. */
  57060. mergeRegionArea: number;
  57061. /**
  57062. * The maximum number of vertices allowed for polygons generated during the
  57063. * contour to polygon conversion process. [Limit: >= 3]
  57064. */
  57065. maxVertsPerPoly: number;
  57066. /**
  57067. * Sets the sampling distance to use when generating the detail mesh.
  57068. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57069. */
  57070. detailSampleDist: number;
  57071. /**
  57072. * The maximum distance the detail mesh surface should deviate from heightfield
  57073. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57074. */
  57075. detailSampleMaxError: number;
  57076. }
  57077. }
  57078. declare module BABYLON {
  57079. /**
  57080. * RecastJS navigation plugin
  57081. */
  57082. export class RecastJSPlugin implements INavigationEnginePlugin {
  57083. /**
  57084. * Reference to the Recast library
  57085. */
  57086. bjsRECAST: any;
  57087. /**
  57088. * plugin name
  57089. */
  57090. name: string;
  57091. /**
  57092. * the first navmesh created. We might extend this to support multiple navmeshes
  57093. */
  57094. navMesh: any;
  57095. /**
  57096. * Initializes the recastJS plugin
  57097. * @param recastInjection can be used to inject your own recast reference
  57098. */
  57099. constructor(recastInjection?: any);
  57100. /**
  57101. * Creates a navigation mesh
  57102. * @param meshes array of all the geometry used to compute the navigatio mesh
  57103. * @param parameters bunch of parameters used to filter geometry
  57104. */
  57105. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57106. /**
  57107. * Create a navigation mesh debug mesh
  57108. * @param scene is where the mesh will be added
  57109. * @returns debug display mesh
  57110. */
  57111. createDebugNavMesh(scene: Scene): Mesh;
  57112. /**
  57113. * Get a navigation mesh constrained position, closest to the parameter position
  57114. * @param position world position
  57115. * @returns the closest point to position constrained by the navigation mesh
  57116. */
  57117. getClosestPoint(position: Vector3): Vector3;
  57118. /**
  57119. * Get a navigation mesh constrained position, within a particular radius
  57120. * @param position world position
  57121. * @param maxRadius the maximum distance to the constrained world position
  57122. * @returns the closest point to position constrained by the navigation mesh
  57123. */
  57124. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57125. /**
  57126. * Compute the final position from a segment made of destination-position
  57127. * @param position world position
  57128. * @param destination world position
  57129. * @returns the resulting point along the navmesh
  57130. */
  57131. moveAlong(position: Vector3, destination: Vector3): Vector3;
  57132. /**
  57133. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57134. * @param start world position
  57135. * @param end world position
  57136. * @returns array containing world position composing the path
  57137. */
  57138. computePath(start: Vector3, end: Vector3): Vector3[];
  57139. /**
  57140. * Create a new Crowd so you can add agents
  57141. * @param maxAgents the maximum agent count in the crowd
  57142. * @param maxAgentRadius the maximum radius an agent can have
  57143. * @param scene to attach the crowd to
  57144. * @returns the crowd you can add agents to
  57145. */
  57146. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57147. /**
  57148. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57149. * The queries will try to find a solution within those bounds
  57150. * default is (1,1,1)
  57151. * @param extent x,y,z value that define the extent around the queries point of reference
  57152. */
  57153. setDefaultQueryExtent(extent: Vector3): void;
  57154. /**
  57155. * Get the Bounding box extent specified by setDefaultQueryExtent
  57156. * @returns the box extent values
  57157. */
  57158. getDefaultQueryExtent(): Vector3;
  57159. /**
  57160. * Disposes
  57161. */
  57162. dispose(): void;
  57163. /**
  57164. * If this plugin is supported
  57165. * @returns true if plugin is supported
  57166. */
  57167. isSupported(): boolean;
  57168. }
  57169. /**
  57170. * Recast detour crowd implementation
  57171. */
  57172. export class RecastJSCrowd implements ICrowd {
  57173. /**
  57174. * Recast/detour plugin
  57175. */
  57176. bjsRECASTPlugin: RecastJSPlugin;
  57177. /**
  57178. * Link to the detour crowd
  57179. */
  57180. recastCrowd: any;
  57181. /**
  57182. * One transform per agent
  57183. */
  57184. transforms: TransformNode[];
  57185. /**
  57186. * All agents created
  57187. */
  57188. agents: number[];
  57189. /**
  57190. * Link to the scene is kept to unregister the crowd from the scene
  57191. */
  57192. private _scene;
  57193. /**
  57194. * Observer for crowd updates
  57195. */
  57196. private _onBeforeAnimationsObserver;
  57197. /**
  57198. * Constructor
  57199. * @param plugin recastJS plugin
  57200. * @param maxAgents the maximum agent count in the crowd
  57201. * @param maxAgentRadius the maximum radius an agent can have
  57202. * @param scene to attach the crowd to
  57203. * @returns the crowd you can add agents to
  57204. */
  57205. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57206. /**
  57207. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57208. * You can attach anything to that node. The node position is updated in the scene update tick.
  57209. * @param pos world position that will be constrained by the navigation mesh
  57210. * @param parameters agent parameters
  57211. * @param transform hooked to the agent that will be update by the scene
  57212. * @returns agent index
  57213. */
  57214. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57215. /**
  57216. * Returns the agent position in world space
  57217. * @param index agent index returned by addAgent
  57218. * @returns world space position
  57219. */
  57220. getAgentPosition(index: number): Vector3;
  57221. /**
  57222. * Returns the agent velocity in world space
  57223. * @param index agent index returned by addAgent
  57224. * @returns world space velocity
  57225. */
  57226. getAgentVelocity(index: number): Vector3;
  57227. /**
  57228. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57229. * @param index agent index returned by addAgent
  57230. * @param destination targeted world position
  57231. */
  57232. agentGoto(index: number, destination: Vector3): void;
  57233. /**
  57234. * remove a particular agent previously created
  57235. * @param index agent index returned by addAgent
  57236. */
  57237. removeAgent(index: number): void;
  57238. /**
  57239. * get the list of all agents attached to this crowd
  57240. * @returns list of agent indices
  57241. */
  57242. getAgents(): number[];
  57243. /**
  57244. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57245. * @param deltaTime in seconds
  57246. */
  57247. update(deltaTime: number): void;
  57248. /**
  57249. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  57250. * The queries will try to find a solution within those bounds
  57251. * default is (1,1,1)
  57252. * @param extent x,y,z value that define the extent around the queries point of reference
  57253. */
  57254. setDefaultQueryExtent(extent: Vector3): void;
  57255. /**
  57256. * Get the Bounding box extent specified by setDefaultQueryExtent
  57257. * @returns the box extent values
  57258. */
  57259. getDefaultQueryExtent(): Vector3;
  57260. /**
  57261. * Release all resources
  57262. */
  57263. dispose(): void;
  57264. }
  57265. }
  57266. declare module BABYLON {
  57267. /**
  57268. * Class used to enable access to IndexedDB
  57269. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57270. */
  57271. export class Database implements IOfflineProvider {
  57272. private _callbackManifestChecked;
  57273. private _currentSceneUrl;
  57274. private _db;
  57275. private _enableSceneOffline;
  57276. private _enableTexturesOffline;
  57277. private _manifestVersionFound;
  57278. private _mustUpdateRessources;
  57279. private _hasReachedQuota;
  57280. private _isSupported;
  57281. private _idbFactory;
  57282. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57283. private static IsUASupportingBlobStorage;
  57284. /**
  57285. * Gets a boolean indicating if Database storate is enabled (off by default)
  57286. */
  57287. static IDBStorageEnabled: boolean;
  57288. /**
  57289. * Gets a boolean indicating if scene must be saved in the database
  57290. */
  57291. readonly enableSceneOffline: boolean;
  57292. /**
  57293. * Gets a boolean indicating if textures must be saved in the database
  57294. */
  57295. readonly enableTexturesOffline: boolean;
  57296. /**
  57297. * Creates a new Database
  57298. * @param urlToScene defines the url to load the scene
  57299. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57300. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57301. */
  57302. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57303. private static _ParseURL;
  57304. private static _ReturnFullUrlLocation;
  57305. private _checkManifestFile;
  57306. /**
  57307. * Open the database and make it available
  57308. * @param successCallback defines the callback to call on success
  57309. * @param errorCallback defines the callback to call on error
  57310. */
  57311. open(successCallback: () => void, errorCallback: () => void): void;
  57312. /**
  57313. * Loads an image from the database
  57314. * @param url defines the url to load from
  57315. * @param image defines the target DOM image
  57316. */
  57317. loadImage(url: string, image: HTMLImageElement): void;
  57318. private _loadImageFromDBAsync;
  57319. private _saveImageIntoDBAsync;
  57320. private _checkVersionFromDB;
  57321. private _loadVersionFromDBAsync;
  57322. private _saveVersionIntoDBAsync;
  57323. /**
  57324. * Loads a file from database
  57325. * @param url defines the URL to load from
  57326. * @param sceneLoaded defines a callback to call on success
  57327. * @param progressCallBack defines a callback to call when progress changed
  57328. * @param errorCallback defines a callback to call on error
  57329. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57330. */
  57331. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57332. private _loadFileAsync;
  57333. private _saveFileAsync;
  57334. /**
  57335. * Validates if xhr data is correct
  57336. * @param xhr defines the request to validate
  57337. * @param dataType defines the expected data type
  57338. * @returns true if data is correct
  57339. */
  57340. private static _ValidateXHRData;
  57341. }
  57342. }
  57343. declare module BABYLON {
  57344. /** @hidden */
  57345. export var gpuUpdateParticlesPixelShader: {
  57346. name: string;
  57347. shader: string;
  57348. };
  57349. }
  57350. declare module BABYLON {
  57351. /** @hidden */
  57352. export var gpuUpdateParticlesVertexShader: {
  57353. name: string;
  57354. shader: string;
  57355. };
  57356. }
  57357. declare module BABYLON {
  57358. /** @hidden */
  57359. export var clipPlaneFragmentDeclaration2: {
  57360. name: string;
  57361. shader: string;
  57362. };
  57363. }
  57364. declare module BABYLON {
  57365. /** @hidden */
  57366. export var gpuRenderParticlesPixelShader: {
  57367. name: string;
  57368. shader: string;
  57369. };
  57370. }
  57371. declare module BABYLON {
  57372. /** @hidden */
  57373. export var clipPlaneVertexDeclaration2: {
  57374. name: string;
  57375. shader: string;
  57376. };
  57377. }
  57378. declare module BABYLON {
  57379. /** @hidden */
  57380. export var gpuRenderParticlesVertexShader: {
  57381. name: string;
  57382. shader: string;
  57383. };
  57384. }
  57385. declare module BABYLON {
  57386. /**
  57387. * This represents a GPU particle system in Babylon
  57388. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57389. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57390. */
  57391. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57392. /**
  57393. * The layer mask we are rendering the particles through.
  57394. */
  57395. layerMask: number;
  57396. private _capacity;
  57397. private _activeCount;
  57398. private _currentActiveCount;
  57399. private _accumulatedCount;
  57400. private _renderEffect;
  57401. private _updateEffect;
  57402. private _buffer0;
  57403. private _buffer1;
  57404. private _spriteBuffer;
  57405. private _updateVAO;
  57406. private _renderVAO;
  57407. private _targetIndex;
  57408. private _sourceBuffer;
  57409. private _targetBuffer;
  57410. private _engine;
  57411. private _currentRenderId;
  57412. private _started;
  57413. private _stopped;
  57414. private _timeDelta;
  57415. private _randomTexture;
  57416. private _randomTexture2;
  57417. private _attributesStrideSize;
  57418. private _updateEffectOptions;
  57419. private _randomTextureSize;
  57420. private _actualFrame;
  57421. private readonly _rawTextureWidth;
  57422. /**
  57423. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57424. */
  57425. static readonly IsSupported: boolean;
  57426. /**
  57427. * An event triggered when the system is disposed.
  57428. */
  57429. onDisposeObservable: Observable<GPUParticleSystem>;
  57430. /**
  57431. * Gets the maximum number of particles active at the same time.
  57432. * @returns The max number of active particles.
  57433. */
  57434. getCapacity(): number;
  57435. /**
  57436. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57437. * to override the particles.
  57438. */
  57439. forceDepthWrite: boolean;
  57440. /**
  57441. * Gets or set the number of active particles
  57442. */
  57443. activeParticleCount: number;
  57444. private _preWarmDone;
  57445. /**
  57446. * Is this system ready to be used/rendered
  57447. * @return true if the system is ready
  57448. */
  57449. isReady(): boolean;
  57450. /**
  57451. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57452. * @returns True if it has been started, otherwise false.
  57453. */
  57454. isStarted(): boolean;
  57455. /**
  57456. * Starts the particle system and begins to emit
  57457. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57458. */
  57459. start(delay?: number): void;
  57460. /**
  57461. * Stops the particle system.
  57462. */
  57463. stop(): void;
  57464. /**
  57465. * Remove all active particles
  57466. */
  57467. reset(): void;
  57468. /**
  57469. * Returns the string "GPUParticleSystem"
  57470. * @returns a string containing the class name
  57471. */
  57472. getClassName(): string;
  57473. private _colorGradientsTexture;
  57474. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57475. /**
  57476. * Adds a new color gradient
  57477. * @param gradient defines the gradient to use (between 0 and 1)
  57478. * @param color1 defines the color to affect to the specified gradient
  57479. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57480. * @returns the current particle system
  57481. */
  57482. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57483. /**
  57484. * Remove a specific color gradient
  57485. * @param gradient defines the gradient to remove
  57486. * @returns the current particle system
  57487. */
  57488. removeColorGradient(gradient: number): GPUParticleSystem;
  57489. private _angularSpeedGradientsTexture;
  57490. private _sizeGradientsTexture;
  57491. private _velocityGradientsTexture;
  57492. private _limitVelocityGradientsTexture;
  57493. private _dragGradientsTexture;
  57494. private _addFactorGradient;
  57495. /**
  57496. * Adds a new size gradient
  57497. * @param gradient defines the gradient to use (between 0 and 1)
  57498. * @param factor defines the size factor to affect to the specified gradient
  57499. * @returns the current particle system
  57500. */
  57501. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57502. /**
  57503. * Remove a specific size gradient
  57504. * @param gradient defines the gradient to remove
  57505. * @returns the current particle system
  57506. */
  57507. removeSizeGradient(gradient: number): GPUParticleSystem;
  57508. /**
  57509. * Adds a new angular speed gradient
  57510. * @param gradient defines the gradient to use (between 0 and 1)
  57511. * @param factor defines the angular speed to affect to the specified gradient
  57512. * @returns the current particle system
  57513. */
  57514. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57515. /**
  57516. * Remove a specific angular speed gradient
  57517. * @param gradient defines the gradient to remove
  57518. * @returns the current particle system
  57519. */
  57520. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57521. /**
  57522. * Adds a new velocity gradient
  57523. * @param gradient defines the gradient to use (between 0 and 1)
  57524. * @param factor defines the velocity to affect to the specified gradient
  57525. * @returns the current particle system
  57526. */
  57527. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57528. /**
  57529. * Remove a specific velocity gradient
  57530. * @param gradient defines the gradient to remove
  57531. * @returns the current particle system
  57532. */
  57533. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57534. /**
  57535. * Adds a new limit velocity gradient
  57536. * @param gradient defines the gradient to use (between 0 and 1)
  57537. * @param factor defines the limit velocity value to affect to the specified gradient
  57538. * @returns the current particle system
  57539. */
  57540. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57541. /**
  57542. * Remove a specific limit velocity gradient
  57543. * @param gradient defines the gradient to remove
  57544. * @returns the current particle system
  57545. */
  57546. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57547. /**
  57548. * Adds a new drag gradient
  57549. * @param gradient defines the gradient to use (between 0 and 1)
  57550. * @param factor defines the drag value to affect to the specified gradient
  57551. * @returns the current particle system
  57552. */
  57553. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57554. /**
  57555. * Remove a specific drag gradient
  57556. * @param gradient defines the gradient to remove
  57557. * @returns the current particle system
  57558. */
  57559. removeDragGradient(gradient: number): GPUParticleSystem;
  57560. /**
  57561. * Not supported by GPUParticleSystem
  57562. * @param gradient defines the gradient to use (between 0 and 1)
  57563. * @param factor defines the emit rate value to affect to the specified gradient
  57564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57565. * @returns the current particle system
  57566. */
  57567. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57568. /**
  57569. * Not supported by GPUParticleSystem
  57570. * @param gradient defines the gradient to remove
  57571. * @returns the current particle system
  57572. */
  57573. removeEmitRateGradient(gradient: number): IParticleSystem;
  57574. /**
  57575. * Not supported by GPUParticleSystem
  57576. * @param gradient defines the gradient to use (between 0 and 1)
  57577. * @param factor defines the start size value to affect to the specified gradient
  57578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57579. * @returns the current particle system
  57580. */
  57581. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57582. /**
  57583. * Not supported by GPUParticleSystem
  57584. * @param gradient defines the gradient to remove
  57585. * @returns the current particle system
  57586. */
  57587. removeStartSizeGradient(gradient: number): IParticleSystem;
  57588. /**
  57589. * Not supported by GPUParticleSystem
  57590. * @param gradient defines the gradient to use (between 0 and 1)
  57591. * @param min defines the color remap minimal range
  57592. * @param max defines the color remap maximal range
  57593. * @returns the current particle system
  57594. */
  57595. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57596. /**
  57597. * Not supported by GPUParticleSystem
  57598. * @param gradient defines the gradient to remove
  57599. * @returns the current particle system
  57600. */
  57601. removeColorRemapGradient(): IParticleSystem;
  57602. /**
  57603. * Not supported by GPUParticleSystem
  57604. * @param gradient defines the gradient to use (between 0 and 1)
  57605. * @param min defines the alpha remap minimal range
  57606. * @param max defines the alpha remap maximal range
  57607. * @returns the current particle system
  57608. */
  57609. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57610. /**
  57611. * Not supported by GPUParticleSystem
  57612. * @param gradient defines the gradient to remove
  57613. * @returns the current particle system
  57614. */
  57615. removeAlphaRemapGradient(): IParticleSystem;
  57616. /**
  57617. * Not supported by GPUParticleSystem
  57618. * @param gradient defines the gradient to use (between 0 and 1)
  57619. * @param color defines the color to affect to the specified gradient
  57620. * @returns the current particle system
  57621. */
  57622. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57623. /**
  57624. * Not supported by GPUParticleSystem
  57625. * @param gradient defines the gradient to remove
  57626. * @returns the current particle system
  57627. */
  57628. removeRampGradient(): IParticleSystem;
  57629. /**
  57630. * Not supported by GPUParticleSystem
  57631. * @returns the list of ramp gradients
  57632. */
  57633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57634. /**
  57635. * Not supported by GPUParticleSystem
  57636. * Gets or sets a boolean indicating that ramp gradients must be used
  57637. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57638. */
  57639. useRampGradients: boolean;
  57640. /**
  57641. * Not supported by GPUParticleSystem
  57642. * @param gradient defines the gradient to use (between 0 and 1)
  57643. * @param factor defines the life time factor to affect to the specified gradient
  57644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57645. * @returns the current particle system
  57646. */
  57647. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57648. /**
  57649. * Not supported by GPUParticleSystem
  57650. * @param gradient defines the gradient to remove
  57651. * @returns the current particle system
  57652. */
  57653. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57654. /**
  57655. * Instantiates a GPU particle system.
  57656. * 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.
  57657. * @param name The name of the particle system
  57658. * @param options The options used to create the system
  57659. * @param scene The scene the particle system belongs to
  57660. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57661. */
  57662. constructor(name: string, options: Partial<{
  57663. capacity: number;
  57664. randomTextureSize: number;
  57665. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57666. protected _reset(): void;
  57667. private _createUpdateVAO;
  57668. private _createRenderVAO;
  57669. private _initialize;
  57670. /** @hidden */
  57671. _recreateUpdateEffect(): void;
  57672. /** @hidden */
  57673. _recreateRenderEffect(): void;
  57674. /**
  57675. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57676. * @param preWarm defines if we are in the pre-warmimg phase
  57677. */
  57678. animate(preWarm?: boolean): void;
  57679. private _createFactorGradientTexture;
  57680. private _createSizeGradientTexture;
  57681. private _createAngularSpeedGradientTexture;
  57682. private _createVelocityGradientTexture;
  57683. private _createLimitVelocityGradientTexture;
  57684. private _createDragGradientTexture;
  57685. private _createColorGradientTexture;
  57686. /**
  57687. * Renders the particle system in its current state
  57688. * @param preWarm defines if the system should only update the particles but not render them
  57689. * @returns the current number of particles
  57690. */
  57691. render(preWarm?: boolean): number;
  57692. /**
  57693. * Rebuilds the particle system
  57694. */
  57695. rebuild(): void;
  57696. private _releaseBuffers;
  57697. private _releaseVAOs;
  57698. /**
  57699. * Disposes the particle system and free the associated resources
  57700. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57701. */
  57702. dispose(disposeTexture?: boolean): void;
  57703. /**
  57704. * Clones the particle system.
  57705. * @param name The name of the cloned object
  57706. * @param newEmitter The new emitter to use
  57707. * @returns the cloned particle system
  57708. */
  57709. clone(name: string, newEmitter: any): GPUParticleSystem;
  57710. /**
  57711. * Serializes the particle system to a JSON object.
  57712. * @returns the JSON object
  57713. */
  57714. serialize(): any;
  57715. /**
  57716. * Parses a JSON object to create a GPU particle system.
  57717. * @param parsedParticleSystem The JSON object to parse
  57718. * @param scene The scene to create the particle system in
  57719. * @param rootUrl The root url to use to load external dependencies like texture
  57720. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57721. * @returns the parsed GPU particle system
  57722. */
  57723. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57724. }
  57725. }
  57726. declare module BABYLON {
  57727. /**
  57728. * Represents a set of particle systems working together to create a specific effect
  57729. */
  57730. export class ParticleSystemSet implements IDisposable {
  57731. private _emitterCreationOptions;
  57732. private _emitterNode;
  57733. /**
  57734. * Gets the particle system list
  57735. */
  57736. systems: IParticleSystem[];
  57737. /**
  57738. * Gets the emitter node used with this set
  57739. */
  57740. readonly emitterNode: Nullable<TransformNode>;
  57741. /**
  57742. * Creates a new emitter mesh as a sphere
  57743. * @param options defines the options used to create the sphere
  57744. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57745. * @param scene defines the hosting scene
  57746. */
  57747. setEmitterAsSphere(options: {
  57748. diameter: number;
  57749. segments: number;
  57750. color: Color3;
  57751. }, renderingGroupId: number, scene: Scene): void;
  57752. /**
  57753. * Starts all particle systems of the set
  57754. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57755. */
  57756. start(emitter?: AbstractMesh): void;
  57757. /**
  57758. * Release all associated resources
  57759. */
  57760. dispose(): void;
  57761. /**
  57762. * Serialize the set into a JSON compatible object
  57763. * @returns a JSON compatible representation of the set
  57764. */
  57765. serialize(): any;
  57766. /**
  57767. * Parse a new ParticleSystemSet from a serialized source
  57768. * @param data defines a JSON compatible representation of the set
  57769. * @param scene defines the hosting scene
  57770. * @param gpu defines if we want GPU particles or CPU particles
  57771. * @returns a new ParticleSystemSet
  57772. */
  57773. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57774. }
  57775. }
  57776. declare module BABYLON {
  57777. /**
  57778. * This class is made for on one-liner static method to help creating particle system set.
  57779. */
  57780. export class ParticleHelper {
  57781. /**
  57782. * Gets or sets base Assets URL
  57783. */
  57784. static BaseAssetsUrl: string;
  57785. /**
  57786. * Create a default particle system that you can tweak
  57787. * @param emitter defines the emitter to use
  57788. * @param capacity defines the system capacity (default is 500 particles)
  57789. * @param scene defines the hosting scene
  57790. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57791. * @returns the new Particle system
  57792. */
  57793. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57794. /**
  57795. * This is the main static method (one-liner) of this helper to create different particle systems
  57796. * @param type This string represents the type to the particle system to create
  57797. * @param scene The scene where the particle system should live
  57798. * @param gpu If the system will use gpu
  57799. * @returns the ParticleSystemSet created
  57800. */
  57801. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57802. /**
  57803. * Static function used to export a particle system to a ParticleSystemSet variable.
  57804. * Please note that the emitter shape is not exported
  57805. * @param systems defines the particle systems to export
  57806. * @returns the created particle system set
  57807. */
  57808. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57809. }
  57810. }
  57811. declare module BABYLON {
  57812. interface Engine {
  57813. /**
  57814. * Create an effect to use with particle systems.
  57815. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57816. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57817. * @param uniformsNames defines a list of attribute names
  57818. * @param samplers defines an array of string used to represent textures
  57819. * @param defines defines the string containing the defines to use to compile the shaders
  57820. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57821. * @param onCompiled defines a function to call when the effect creation is successful
  57822. * @param onError defines a function to call when the effect creation has failed
  57823. * @returns the new Effect
  57824. */
  57825. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57826. }
  57827. interface Mesh {
  57828. /**
  57829. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57830. * @returns an array of IParticleSystem
  57831. */
  57832. getEmittedParticleSystems(): IParticleSystem[];
  57833. /**
  57834. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57835. * @returns an array of IParticleSystem
  57836. */
  57837. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57838. }
  57839. /**
  57840. * @hidden
  57841. */
  57842. export var _IDoNeedToBeInTheBuild: number;
  57843. }
  57844. declare module BABYLON {
  57845. interface Scene {
  57846. /** @hidden (Backing field) */
  57847. _physicsEngine: Nullable<IPhysicsEngine>;
  57848. /**
  57849. * Gets the current physics engine
  57850. * @returns a IPhysicsEngine or null if none attached
  57851. */
  57852. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57853. /**
  57854. * Enables physics to the current scene
  57855. * @param gravity defines the scene's gravity for the physics engine
  57856. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57857. * @return a boolean indicating if the physics engine was initialized
  57858. */
  57859. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57860. /**
  57861. * Disables and disposes the physics engine associated with the scene
  57862. */
  57863. disablePhysicsEngine(): void;
  57864. /**
  57865. * Gets a boolean indicating if there is an active physics engine
  57866. * @returns a boolean indicating if there is an active physics engine
  57867. */
  57868. isPhysicsEnabled(): boolean;
  57869. /**
  57870. * Deletes a physics compound impostor
  57871. * @param compound defines the compound to delete
  57872. */
  57873. deleteCompoundImpostor(compound: any): void;
  57874. /**
  57875. * An event triggered when physic simulation is about to be run
  57876. */
  57877. onBeforePhysicsObservable: Observable<Scene>;
  57878. /**
  57879. * An event triggered when physic simulation has been done
  57880. */
  57881. onAfterPhysicsObservable: Observable<Scene>;
  57882. }
  57883. interface AbstractMesh {
  57884. /** @hidden */
  57885. _physicsImpostor: Nullable<PhysicsImpostor>;
  57886. /**
  57887. * Gets or sets impostor used for physic simulation
  57888. * @see http://doc.babylonjs.com/features/physics_engine
  57889. */
  57890. physicsImpostor: Nullable<PhysicsImpostor>;
  57891. /**
  57892. * Gets the current physics impostor
  57893. * @see http://doc.babylonjs.com/features/physics_engine
  57894. * @returns a physics impostor or null
  57895. */
  57896. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57897. /** Apply a physic impulse to the mesh
  57898. * @param force defines the force to apply
  57899. * @param contactPoint defines where to apply the force
  57900. * @returns the current mesh
  57901. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57902. */
  57903. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57904. /**
  57905. * Creates a physic joint between two meshes
  57906. * @param otherMesh defines the other mesh to use
  57907. * @param pivot1 defines the pivot to use on this mesh
  57908. * @param pivot2 defines the pivot to use on the other mesh
  57909. * @param options defines additional options (can be plugin dependent)
  57910. * @returns the current mesh
  57911. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57912. */
  57913. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57914. /** @hidden */
  57915. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57916. }
  57917. /**
  57918. * Defines the physics engine scene component responsible to manage a physics engine
  57919. */
  57920. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57921. /**
  57922. * The component name helpful to identify the component in the list of scene components.
  57923. */
  57924. readonly name: string;
  57925. /**
  57926. * The scene the component belongs to.
  57927. */
  57928. scene: Scene;
  57929. /**
  57930. * Creates a new instance of the component for the given scene
  57931. * @param scene Defines the scene to register the component in
  57932. */
  57933. constructor(scene: Scene);
  57934. /**
  57935. * Registers the component in a given scene
  57936. */
  57937. register(): void;
  57938. /**
  57939. * Rebuilds the elements related to this component in case of
  57940. * context lost for instance.
  57941. */
  57942. rebuild(): void;
  57943. /**
  57944. * Disposes the component and the associated ressources
  57945. */
  57946. dispose(): void;
  57947. }
  57948. }
  57949. declare module BABYLON {
  57950. /**
  57951. * A helper for physics simulations
  57952. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57953. */
  57954. export class PhysicsHelper {
  57955. private _scene;
  57956. private _physicsEngine;
  57957. /**
  57958. * Initializes the Physics helper
  57959. * @param scene Babylon.js scene
  57960. */
  57961. constructor(scene: Scene);
  57962. /**
  57963. * Applies a radial explosion impulse
  57964. * @param origin the origin of the explosion
  57965. * @param radiusOrEventOptions the radius or the options of radial explosion
  57966. * @param strength the explosion strength
  57967. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57968. * @returns A physics radial explosion event, or null
  57969. */
  57970. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57971. /**
  57972. * Applies a radial explosion force
  57973. * @param origin the origin of the explosion
  57974. * @param radiusOrEventOptions the radius or the options of radial explosion
  57975. * @param strength the explosion strength
  57976. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57977. * @returns A physics radial explosion event, or null
  57978. */
  57979. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57980. /**
  57981. * Creates a gravitational field
  57982. * @param origin the origin of the explosion
  57983. * @param radiusOrEventOptions the radius or the options of radial explosion
  57984. * @param strength the explosion strength
  57985. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57986. * @returns A physics gravitational field event, or null
  57987. */
  57988. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57989. /**
  57990. * Creates a physics updraft event
  57991. * @param origin the origin of the updraft
  57992. * @param radiusOrEventOptions the radius or the options of the updraft
  57993. * @param strength the strength of the updraft
  57994. * @param height the height of the updraft
  57995. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57996. * @returns A physics updraft event, or null
  57997. */
  57998. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57999. /**
  58000. * Creates a physics vortex event
  58001. * @param origin the of the vortex
  58002. * @param radiusOrEventOptions the radius or the options of the vortex
  58003. * @param strength the strength of the vortex
  58004. * @param height the height of the vortex
  58005. * @returns a Physics vortex event, or null
  58006. * A physics vortex event or null
  58007. */
  58008. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58009. }
  58010. /**
  58011. * Represents a physics radial explosion event
  58012. */
  58013. class PhysicsRadialExplosionEvent {
  58014. private _scene;
  58015. private _options;
  58016. private _sphere;
  58017. private _dataFetched;
  58018. /**
  58019. * Initializes a radial explosioin event
  58020. * @param _scene BabylonJS scene
  58021. * @param _options The options for the vortex event
  58022. */
  58023. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58024. /**
  58025. * Returns the data related to the radial explosion event (sphere).
  58026. * @returns The radial explosion event data
  58027. */
  58028. getData(): PhysicsRadialExplosionEventData;
  58029. /**
  58030. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58031. * @param impostor A physics imposter
  58032. * @param origin the origin of the explosion
  58033. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58034. */
  58035. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58036. /**
  58037. * Triggers affecterd impostors callbacks
  58038. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58039. */
  58040. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58041. /**
  58042. * Disposes the sphere.
  58043. * @param force Specifies if the sphere should be disposed by force
  58044. */
  58045. dispose(force?: boolean): void;
  58046. /*** Helpers ***/
  58047. private _prepareSphere;
  58048. private _intersectsWithSphere;
  58049. }
  58050. /**
  58051. * Represents a gravitational field event
  58052. */
  58053. class PhysicsGravitationalFieldEvent {
  58054. private _physicsHelper;
  58055. private _scene;
  58056. private _origin;
  58057. private _options;
  58058. private _tickCallback;
  58059. private _sphere;
  58060. private _dataFetched;
  58061. /**
  58062. * Initializes the physics gravitational field event
  58063. * @param _physicsHelper A physics helper
  58064. * @param _scene BabylonJS scene
  58065. * @param _origin The origin position of the gravitational field event
  58066. * @param _options The options for the vortex event
  58067. */
  58068. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58069. /**
  58070. * Returns the data related to the gravitational field event (sphere).
  58071. * @returns A gravitational field event
  58072. */
  58073. getData(): PhysicsGravitationalFieldEventData;
  58074. /**
  58075. * Enables the gravitational field.
  58076. */
  58077. enable(): void;
  58078. /**
  58079. * Disables the gravitational field.
  58080. */
  58081. disable(): void;
  58082. /**
  58083. * Disposes the sphere.
  58084. * @param force The force to dispose from the gravitational field event
  58085. */
  58086. dispose(force?: boolean): void;
  58087. private _tick;
  58088. }
  58089. /**
  58090. * Represents a physics updraft event
  58091. */
  58092. class PhysicsUpdraftEvent {
  58093. private _scene;
  58094. private _origin;
  58095. private _options;
  58096. private _physicsEngine;
  58097. private _originTop;
  58098. private _originDirection;
  58099. private _tickCallback;
  58100. private _cylinder;
  58101. private _cylinderPosition;
  58102. private _dataFetched;
  58103. /**
  58104. * Initializes the physics updraft event
  58105. * @param _scene BabylonJS scene
  58106. * @param _origin The origin position of the updraft
  58107. * @param _options The options for the updraft event
  58108. */
  58109. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58110. /**
  58111. * Returns the data related to the updraft event (cylinder).
  58112. * @returns A physics updraft event
  58113. */
  58114. getData(): PhysicsUpdraftEventData;
  58115. /**
  58116. * Enables the updraft.
  58117. */
  58118. enable(): void;
  58119. /**
  58120. * Disables the updraft.
  58121. */
  58122. disable(): void;
  58123. /**
  58124. * Disposes the cylinder.
  58125. * @param force Specifies if the updraft should be disposed by force
  58126. */
  58127. dispose(force?: boolean): void;
  58128. private getImpostorHitData;
  58129. private _tick;
  58130. /*** Helpers ***/
  58131. private _prepareCylinder;
  58132. private _intersectsWithCylinder;
  58133. }
  58134. /**
  58135. * Represents a physics vortex event
  58136. */
  58137. class PhysicsVortexEvent {
  58138. private _scene;
  58139. private _origin;
  58140. private _options;
  58141. private _physicsEngine;
  58142. private _originTop;
  58143. private _tickCallback;
  58144. private _cylinder;
  58145. private _cylinderPosition;
  58146. private _dataFetched;
  58147. /**
  58148. * Initializes the physics vortex event
  58149. * @param _scene The BabylonJS scene
  58150. * @param _origin The origin position of the vortex
  58151. * @param _options The options for the vortex event
  58152. */
  58153. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58154. /**
  58155. * Returns the data related to the vortex event (cylinder).
  58156. * @returns The physics vortex event data
  58157. */
  58158. getData(): PhysicsVortexEventData;
  58159. /**
  58160. * Enables the vortex.
  58161. */
  58162. enable(): void;
  58163. /**
  58164. * Disables the cortex.
  58165. */
  58166. disable(): void;
  58167. /**
  58168. * Disposes the sphere.
  58169. * @param force
  58170. */
  58171. dispose(force?: boolean): void;
  58172. private getImpostorHitData;
  58173. private _tick;
  58174. /*** Helpers ***/
  58175. private _prepareCylinder;
  58176. private _intersectsWithCylinder;
  58177. }
  58178. /**
  58179. * Options fot the radial explosion event
  58180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58181. */
  58182. export class PhysicsRadialExplosionEventOptions {
  58183. /**
  58184. * The radius of the sphere for the radial explosion.
  58185. */
  58186. radius: number;
  58187. /**
  58188. * The strenth of the explosion.
  58189. */
  58190. strength: number;
  58191. /**
  58192. * The strenght of the force in correspondence to the distance of the affected object
  58193. */
  58194. falloff: PhysicsRadialImpulseFalloff;
  58195. /**
  58196. * Sphere options for the radial explosion.
  58197. */
  58198. sphere: {
  58199. segments: number;
  58200. diameter: number;
  58201. };
  58202. /**
  58203. * Sphere options for the radial explosion.
  58204. */
  58205. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58206. }
  58207. /**
  58208. * Options fot the updraft event
  58209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58210. */
  58211. export class PhysicsUpdraftEventOptions {
  58212. /**
  58213. * The radius of the cylinder for the vortex
  58214. */
  58215. radius: number;
  58216. /**
  58217. * The strenth of the updraft.
  58218. */
  58219. strength: number;
  58220. /**
  58221. * The height of the cylinder for the updraft.
  58222. */
  58223. height: number;
  58224. /**
  58225. * The mode for the the updraft.
  58226. */
  58227. updraftMode: PhysicsUpdraftMode;
  58228. }
  58229. /**
  58230. * Options fot the vortex event
  58231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58232. */
  58233. export class PhysicsVortexEventOptions {
  58234. /**
  58235. * The radius of the cylinder for the vortex
  58236. */
  58237. radius: number;
  58238. /**
  58239. * The strenth of the vortex.
  58240. */
  58241. strength: number;
  58242. /**
  58243. * The height of the cylinder for the vortex.
  58244. */
  58245. height: number;
  58246. /**
  58247. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58248. */
  58249. centripetalForceThreshold: number;
  58250. /**
  58251. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58252. */
  58253. centripetalForceMultiplier: number;
  58254. /**
  58255. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58256. */
  58257. centrifugalForceMultiplier: number;
  58258. /**
  58259. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58260. */
  58261. updraftForceMultiplier: number;
  58262. }
  58263. /**
  58264. * The strenght of the force in correspondence to the distance of the affected object
  58265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58266. */
  58267. export enum PhysicsRadialImpulseFalloff {
  58268. /** Defines that impulse is constant in strength across it's whole radius */
  58269. Constant = 0,
  58270. /** Defines that impulse gets weaker if it's further from the origin */
  58271. Linear = 1
  58272. }
  58273. /**
  58274. * The strength of the force in correspondence to the distance of the affected object
  58275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58276. */
  58277. export enum PhysicsUpdraftMode {
  58278. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58279. Center = 0,
  58280. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58281. Perpendicular = 1
  58282. }
  58283. /**
  58284. * Interface for a physics hit data
  58285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58286. */
  58287. export interface PhysicsHitData {
  58288. /**
  58289. * The force applied at the contact point
  58290. */
  58291. force: Vector3;
  58292. /**
  58293. * The contact point
  58294. */
  58295. contactPoint: Vector3;
  58296. /**
  58297. * The distance from the origin to the contact point
  58298. */
  58299. distanceFromOrigin: number;
  58300. }
  58301. /**
  58302. * Interface for radial explosion event data
  58303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58304. */
  58305. export interface PhysicsRadialExplosionEventData {
  58306. /**
  58307. * A sphere used for the radial explosion event
  58308. */
  58309. sphere: Mesh;
  58310. }
  58311. /**
  58312. * Interface for gravitational field event data
  58313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58314. */
  58315. export interface PhysicsGravitationalFieldEventData {
  58316. /**
  58317. * A sphere mesh used for the gravitational field event
  58318. */
  58319. sphere: Mesh;
  58320. }
  58321. /**
  58322. * Interface for updraft event data
  58323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58324. */
  58325. export interface PhysicsUpdraftEventData {
  58326. /**
  58327. * A cylinder used for the updraft event
  58328. */
  58329. cylinder: Mesh;
  58330. }
  58331. /**
  58332. * Interface for vortex event data
  58333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58334. */
  58335. export interface PhysicsVortexEventData {
  58336. /**
  58337. * A cylinder used for the vortex event
  58338. */
  58339. cylinder: Mesh;
  58340. }
  58341. /**
  58342. * Interface for an affected physics impostor
  58343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58344. */
  58345. export interface PhysicsAffectedImpostorWithData {
  58346. /**
  58347. * The impostor affected by the effect
  58348. */
  58349. impostor: PhysicsImpostor;
  58350. /**
  58351. * The data about the hit/horce from the explosion
  58352. */
  58353. hitData: PhysicsHitData;
  58354. }
  58355. }
  58356. declare module BABYLON {
  58357. /** @hidden */
  58358. export var blackAndWhitePixelShader: {
  58359. name: string;
  58360. shader: string;
  58361. };
  58362. }
  58363. declare module BABYLON {
  58364. /**
  58365. * Post process used to render in black and white
  58366. */
  58367. export class BlackAndWhitePostProcess extends PostProcess {
  58368. /**
  58369. * Linear about to convert he result to black and white (default: 1)
  58370. */
  58371. degree: number;
  58372. /**
  58373. * Creates a black and white post process
  58374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58375. * @param name The name of the effect.
  58376. * @param options The required width/height ratio to downsize to before computing the render pass.
  58377. * @param camera The camera to apply the render pass to.
  58378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58379. * @param engine The engine which the post process will be applied. (default: current engine)
  58380. * @param reusable If the post process can be reused on the same frame. (default: false)
  58381. */
  58382. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58383. }
  58384. }
  58385. declare module BABYLON {
  58386. /**
  58387. * This represents a set of one or more post processes in Babylon.
  58388. * A post process can be used to apply a shader to a texture after it is rendered.
  58389. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58390. */
  58391. export class PostProcessRenderEffect {
  58392. private _postProcesses;
  58393. private _getPostProcesses;
  58394. private _singleInstance;
  58395. private _cameras;
  58396. private _indicesForCamera;
  58397. /**
  58398. * Name of the effect
  58399. * @hidden
  58400. */
  58401. _name: string;
  58402. /**
  58403. * Instantiates a post process render effect.
  58404. * A post process can be used to apply a shader to a texture after it is rendered.
  58405. * @param engine The engine the effect is tied to
  58406. * @param name The name of the effect
  58407. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58408. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58409. */
  58410. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58411. /**
  58412. * Checks if all the post processes in the effect are supported.
  58413. */
  58414. readonly isSupported: boolean;
  58415. /**
  58416. * Updates the current state of the effect
  58417. * @hidden
  58418. */
  58419. _update(): void;
  58420. /**
  58421. * Attaches the effect on cameras
  58422. * @param cameras The camera to attach to.
  58423. * @hidden
  58424. */
  58425. _attachCameras(cameras: Camera): void;
  58426. /**
  58427. * Attaches the effect on cameras
  58428. * @param cameras The camera to attach to.
  58429. * @hidden
  58430. */
  58431. _attachCameras(cameras: Camera[]): void;
  58432. /**
  58433. * Detaches the effect on cameras
  58434. * @param cameras The camera to detatch from.
  58435. * @hidden
  58436. */
  58437. _detachCameras(cameras: Camera): void;
  58438. /**
  58439. * Detatches the effect on cameras
  58440. * @param cameras The camera to detatch from.
  58441. * @hidden
  58442. */
  58443. _detachCameras(cameras: Camera[]): void;
  58444. /**
  58445. * Enables the effect on given cameras
  58446. * @param cameras The camera to enable.
  58447. * @hidden
  58448. */
  58449. _enable(cameras: Camera): void;
  58450. /**
  58451. * Enables the effect on given cameras
  58452. * @param cameras The camera to enable.
  58453. * @hidden
  58454. */
  58455. _enable(cameras: Nullable<Camera[]>): void;
  58456. /**
  58457. * Disables the effect on the given cameras
  58458. * @param cameras The camera to disable.
  58459. * @hidden
  58460. */
  58461. _disable(cameras: Camera): void;
  58462. /**
  58463. * Disables the effect on the given cameras
  58464. * @param cameras The camera to disable.
  58465. * @hidden
  58466. */
  58467. _disable(cameras: Nullable<Camera[]>): void;
  58468. /**
  58469. * Gets a list of the post processes contained in the effect.
  58470. * @param camera The camera to get the post processes on.
  58471. * @returns The list of the post processes in the effect.
  58472. */
  58473. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58474. }
  58475. }
  58476. declare module BABYLON {
  58477. /** @hidden */
  58478. export var extractHighlightsPixelShader: {
  58479. name: string;
  58480. shader: string;
  58481. };
  58482. }
  58483. declare module BABYLON {
  58484. /**
  58485. * 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.
  58486. */
  58487. export class ExtractHighlightsPostProcess extends PostProcess {
  58488. /**
  58489. * The luminance threshold, pixels below this value will be set to black.
  58490. */
  58491. threshold: number;
  58492. /** @hidden */
  58493. _exposure: number;
  58494. /**
  58495. * Post process which has the input texture to be used when performing highlight extraction
  58496. * @hidden
  58497. */
  58498. _inputPostProcess: Nullable<PostProcess>;
  58499. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58500. }
  58501. }
  58502. declare module BABYLON {
  58503. /** @hidden */
  58504. export var bloomMergePixelShader: {
  58505. name: string;
  58506. shader: string;
  58507. };
  58508. }
  58509. declare module BABYLON {
  58510. /**
  58511. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58512. */
  58513. export class BloomMergePostProcess extends PostProcess {
  58514. /** Weight of the bloom to be added to the original input. */
  58515. weight: number;
  58516. /**
  58517. * Creates a new instance of @see BloomMergePostProcess
  58518. * @param name The name of the effect.
  58519. * @param originalFromInput Post process which's input will be used for the merge.
  58520. * @param blurred Blurred highlights post process which's output will be used.
  58521. * @param weight Weight of the bloom to be added to the original input.
  58522. * @param options The required width/height ratio to downsize to before computing the render pass.
  58523. * @param camera The camera to apply the render pass to.
  58524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58525. * @param engine The engine which the post process will be applied. (default: current engine)
  58526. * @param reusable If the post process can be reused on the same frame. (default: false)
  58527. * @param textureType Type of textures used when performing the post process. (default: 0)
  58528. * @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)
  58529. */
  58530. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58531. /** Weight of the bloom to be added to the original input. */
  58532. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58533. }
  58534. }
  58535. declare module BABYLON {
  58536. /**
  58537. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58538. */
  58539. export class BloomEffect extends PostProcessRenderEffect {
  58540. private bloomScale;
  58541. /**
  58542. * @hidden Internal
  58543. */
  58544. _effects: Array<PostProcess>;
  58545. /**
  58546. * @hidden Internal
  58547. */
  58548. _downscale: ExtractHighlightsPostProcess;
  58549. private _blurX;
  58550. private _blurY;
  58551. private _merge;
  58552. /**
  58553. * The luminance threshold to find bright areas of the image to bloom.
  58554. */
  58555. threshold: number;
  58556. /**
  58557. * The strength of the bloom.
  58558. */
  58559. weight: number;
  58560. /**
  58561. * Specifies the size of the bloom blur kernel, relative to the final output size
  58562. */
  58563. kernel: number;
  58564. /**
  58565. * Creates a new instance of @see BloomEffect
  58566. * @param scene The scene the effect belongs to.
  58567. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58568. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58569. * @param bloomWeight The the strength of bloom.
  58570. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58571. * @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)
  58572. */
  58573. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58574. /**
  58575. * Disposes each of the internal effects for a given camera.
  58576. * @param camera The camera to dispose the effect on.
  58577. */
  58578. disposeEffects(camera: Camera): void;
  58579. /**
  58580. * @hidden Internal
  58581. */
  58582. _updateEffects(): void;
  58583. /**
  58584. * Internal
  58585. * @returns if all the contained post processes are ready.
  58586. * @hidden
  58587. */
  58588. _isReady(): boolean;
  58589. }
  58590. }
  58591. declare module BABYLON {
  58592. /** @hidden */
  58593. export var chromaticAberrationPixelShader: {
  58594. name: string;
  58595. shader: string;
  58596. };
  58597. }
  58598. declare module BABYLON {
  58599. /**
  58600. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58601. */
  58602. export class ChromaticAberrationPostProcess extends PostProcess {
  58603. /**
  58604. * The amount of seperation of rgb channels (default: 30)
  58605. */
  58606. aberrationAmount: number;
  58607. /**
  58608. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58609. */
  58610. radialIntensity: number;
  58611. /**
  58612. * 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))
  58613. */
  58614. direction: Vector2;
  58615. /**
  58616. * 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))
  58617. */
  58618. centerPosition: Vector2;
  58619. /**
  58620. * Creates a new instance ChromaticAberrationPostProcess
  58621. * @param name The name of the effect.
  58622. * @param screenWidth The width of the screen to apply the effect on.
  58623. * @param screenHeight The height of the screen to apply the effect on.
  58624. * @param options The required width/height ratio to downsize to before computing the render pass.
  58625. * @param camera The camera to apply the render pass to.
  58626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58627. * @param engine The engine which the post process will be applied. (default: current engine)
  58628. * @param reusable If the post process can be reused on the same frame. (default: false)
  58629. * @param textureType Type of textures used when performing the post process. (default: 0)
  58630. * @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)
  58631. */
  58632. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58633. }
  58634. }
  58635. declare module BABYLON {
  58636. /** @hidden */
  58637. export var circleOfConfusionPixelShader: {
  58638. name: string;
  58639. shader: string;
  58640. };
  58641. }
  58642. declare module BABYLON {
  58643. /**
  58644. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58645. */
  58646. export class CircleOfConfusionPostProcess extends PostProcess {
  58647. /**
  58648. * 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.
  58649. */
  58650. lensSize: number;
  58651. /**
  58652. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58653. */
  58654. fStop: number;
  58655. /**
  58656. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58657. */
  58658. focusDistance: number;
  58659. /**
  58660. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58661. */
  58662. focalLength: number;
  58663. private _depthTexture;
  58664. /**
  58665. * Creates a new instance CircleOfConfusionPostProcess
  58666. * @param name The name of the effect.
  58667. * @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.
  58668. * @param options The required width/height ratio to downsize to before computing the render pass.
  58669. * @param camera The camera to apply the render pass to.
  58670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58671. * @param engine The engine which the post process will be applied. (default: current engine)
  58672. * @param reusable If the post process can be reused on the same frame. (default: false)
  58673. * @param textureType Type of textures used when performing the post process. (default: 0)
  58674. * @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)
  58675. */
  58676. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58677. /**
  58678. * 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.
  58679. */
  58680. depthTexture: RenderTargetTexture;
  58681. }
  58682. }
  58683. declare module BABYLON {
  58684. /** @hidden */
  58685. export var colorCorrectionPixelShader: {
  58686. name: string;
  58687. shader: string;
  58688. };
  58689. }
  58690. declare module BABYLON {
  58691. /**
  58692. *
  58693. * This post-process allows the modification of rendered colors by using
  58694. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58695. *
  58696. * The object needs to be provided an url to a texture containing the color
  58697. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58698. * Use an image editing software to tweak the LUT to match your needs.
  58699. *
  58700. * For an example of a color LUT, see here:
  58701. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58702. * For explanations on color grading, see here:
  58703. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58704. *
  58705. */
  58706. export class ColorCorrectionPostProcess extends PostProcess {
  58707. private _colorTableTexture;
  58708. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58709. }
  58710. }
  58711. declare module BABYLON {
  58712. /** @hidden */
  58713. export var convolutionPixelShader: {
  58714. name: string;
  58715. shader: string;
  58716. };
  58717. }
  58718. declare module BABYLON {
  58719. /**
  58720. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58721. * input texture to perform effects such as edge detection or sharpening
  58722. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58723. */
  58724. export class ConvolutionPostProcess extends PostProcess {
  58725. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58726. kernel: number[];
  58727. /**
  58728. * Creates a new instance ConvolutionPostProcess
  58729. * @param name The name of the effect.
  58730. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58731. * @param options The required width/height ratio to downsize to before computing the render pass.
  58732. * @param camera The camera to apply the render pass to.
  58733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58734. * @param engine The engine which the post process will be applied. (default: current engine)
  58735. * @param reusable If the post process can be reused on the same frame. (default: false)
  58736. * @param textureType Type of textures used when performing the post process. (default: 0)
  58737. */
  58738. constructor(name: string,
  58739. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58740. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58741. /**
  58742. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58743. */
  58744. static EdgeDetect0Kernel: number[];
  58745. /**
  58746. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58747. */
  58748. static EdgeDetect1Kernel: number[];
  58749. /**
  58750. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58751. */
  58752. static EdgeDetect2Kernel: number[];
  58753. /**
  58754. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58755. */
  58756. static SharpenKernel: number[];
  58757. /**
  58758. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58759. */
  58760. static EmbossKernel: number[];
  58761. /**
  58762. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58763. */
  58764. static GaussianKernel: number[];
  58765. }
  58766. }
  58767. declare module BABYLON {
  58768. /**
  58769. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58770. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58771. * based on samples that have a large difference in distance than the center pixel.
  58772. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58773. */
  58774. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58775. direction: Vector2;
  58776. /**
  58777. * Creates a new instance CircleOfConfusionPostProcess
  58778. * @param name The name of the effect.
  58779. * @param scene The scene the effect belongs to.
  58780. * @param direction The direction the blur should be applied.
  58781. * @param kernel The size of the kernel used to blur.
  58782. * @param options The required width/height ratio to downsize to before computing the render pass.
  58783. * @param camera The camera to apply the render pass to.
  58784. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58785. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58787. * @param engine The engine which the post process will be applied. (default: current engine)
  58788. * @param reusable If the post process can be reused on the same frame. (default: false)
  58789. * @param textureType Type of textures used when performing the post process. (default: 0)
  58790. * @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)
  58791. */
  58792. 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);
  58793. }
  58794. }
  58795. declare module BABYLON {
  58796. /** @hidden */
  58797. export var depthOfFieldMergePixelShader: {
  58798. name: string;
  58799. shader: string;
  58800. };
  58801. }
  58802. declare module BABYLON {
  58803. /**
  58804. * Options to be set when merging outputs from the default pipeline.
  58805. */
  58806. export class DepthOfFieldMergePostProcessOptions {
  58807. /**
  58808. * The original image to merge on top of
  58809. */
  58810. originalFromInput: PostProcess;
  58811. /**
  58812. * Parameters to perform the merge of the depth of field effect
  58813. */
  58814. depthOfField?: {
  58815. circleOfConfusion: PostProcess;
  58816. blurSteps: Array<PostProcess>;
  58817. };
  58818. /**
  58819. * Parameters to perform the merge of bloom effect
  58820. */
  58821. bloom?: {
  58822. blurred: PostProcess;
  58823. weight: number;
  58824. };
  58825. }
  58826. /**
  58827. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58828. */
  58829. export class DepthOfFieldMergePostProcess extends PostProcess {
  58830. private blurSteps;
  58831. /**
  58832. * Creates a new instance of DepthOfFieldMergePostProcess
  58833. * @param name The name of the effect.
  58834. * @param originalFromInput Post process which's input will be used for the merge.
  58835. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58836. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58837. * @param options The required width/height ratio to downsize to before computing the render pass.
  58838. * @param camera The camera to apply the render pass to.
  58839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58840. * @param engine The engine which the post process will be applied. (default: current engine)
  58841. * @param reusable If the post process can be reused on the same frame. (default: false)
  58842. * @param textureType Type of textures used when performing the post process. (default: 0)
  58843. * @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)
  58844. */
  58845. 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);
  58846. /**
  58847. * Updates the effect with the current post process compile time values and recompiles the shader.
  58848. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58849. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58850. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58851. * @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
  58852. * @param onCompiled Called when the shader has been compiled.
  58853. * @param onError Called if there is an error when compiling a shader.
  58854. */
  58855. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58856. }
  58857. }
  58858. declare module BABYLON {
  58859. /**
  58860. * Specifies the level of max blur that should be applied when using the depth of field effect
  58861. */
  58862. export enum DepthOfFieldEffectBlurLevel {
  58863. /**
  58864. * Subtle blur
  58865. */
  58866. Low = 0,
  58867. /**
  58868. * Medium blur
  58869. */
  58870. Medium = 1,
  58871. /**
  58872. * Large blur
  58873. */
  58874. High = 2
  58875. }
  58876. /**
  58877. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58878. */
  58879. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58880. private _circleOfConfusion;
  58881. /**
  58882. * @hidden Internal, blurs from high to low
  58883. */
  58884. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58885. private _depthOfFieldBlurY;
  58886. private _dofMerge;
  58887. /**
  58888. * @hidden Internal post processes in depth of field effect
  58889. */
  58890. _effects: Array<PostProcess>;
  58891. /**
  58892. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58893. */
  58894. focalLength: number;
  58895. /**
  58896. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58897. */
  58898. fStop: number;
  58899. /**
  58900. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58901. */
  58902. focusDistance: number;
  58903. /**
  58904. * 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.
  58905. */
  58906. lensSize: number;
  58907. /**
  58908. * Creates a new instance DepthOfFieldEffect
  58909. * @param scene The scene the effect belongs to.
  58910. * @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.
  58911. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58912. * @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)
  58913. */
  58914. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58915. /**
  58916. * Get the current class name of the current effet
  58917. * @returns "DepthOfFieldEffect"
  58918. */
  58919. getClassName(): string;
  58920. /**
  58921. * 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.
  58922. */
  58923. depthTexture: RenderTargetTexture;
  58924. /**
  58925. * Disposes each of the internal effects for a given camera.
  58926. * @param camera The camera to dispose the effect on.
  58927. */
  58928. disposeEffects(camera: Camera): void;
  58929. /**
  58930. * @hidden Internal
  58931. */
  58932. _updateEffects(): void;
  58933. /**
  58934. * Internal
  58935. * @returns if all the contained post processes are ready.
  58936. * @hidden
  58937. */
  58938. _isReady(): boolean;
  58939. }
  58940. }
  58941. declare module BABYLON {
  58942. /** @hidden */
  58943. export var displayPassPixelShader: {
  58944. name: string;
  58945. shader: string;
  58946. };
  58947. }
  58948. declare module BABYLON {
  58949. /**
  58950. * DisplayPassPostProcess which produces an output the same as it's input
  58951. */
  58952. export class DisplayPassPostProcess extends PostProcess {
  58953. /**
  58954. * Creates the DisplayPassPostProcess
  58955. * @param name The name of the effect.
  58956. * @param options The required width/height ratio to downsize to before computing the render pass.
  58957. * @param camera The camera to apply the render pass to.
  58958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58959. * @param engine The engine which the post process will be applied. (default: current engine)
  58960. * @param reusable If the post process can be reused on the same frame. (default: false)
  58961. */
  58962. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58963. }
  58964. }
  58965. declare module BABYLON {
  58966. /** @hidden */
  58967. export var filterPixelShader: {
  58968. name: string;
  58969. shader: string;
  58970. };
  58971. }
  58972. declare module BABYLON {
  58973. /**
  58974. * Applies a kernel filter to the image
  58975. */
  58976. export class FilterPostProcess extends PostProcess {
  58977. /** The matrix to be applied to the image */
  58978. kernelMatrix: Matrix;
  58979. /**
  58980. *
  58981. * @param name The name of the effect.
  58982. * @param kernelMatrix The matrix to be applied to the image
  58983. * @param options The required width/height ratio to downsize to before computing the render pass.
  58984. * @param camera The camera to apply the render pass to.
  58985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58986. * @param engine The engine which the post process will be applied. (default: current engine)
  58987. * @param reusable If the post process can be reused on the same frame. (default: false)
  58988. */
  58989. constructor(name: string,
  58990. /** The matrix to be applied to the image */
  58991. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58992. }
  58993. }
  58994. declare module BABYLON {
  58995. /** @hidden */
  58996. export var fxaaPixelShader: {
  58997. name: string;
  58998. shader: string;
  58999. };
  59000. }
  59001. declare module BABYLON {
  59002. /** @hidden */
  59003. export var fxaaVertexShader: {
  59004. name: string;
  59005. shader: string;
  59006. };
  59007. }
  59008. declare module BABYLON {
  59009. /**
  59010. * Fxaa post process
  59011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59012. */
  59013. export class FxaaPostProcess extends PostProcess {
  59014. /** @hidden */
  59015. texelWidth: number;
  59016. /** @hidden */
  59017. texelHeight: number;
  59018. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59019. private _getDefines;
  59020. }
  59021. }
  59022. declare module BABYLON {
  59023. /** @hidden */
  59024. export var grainPixelShader: {
  59025. name: string;
  59026. shader: string;
  59027. };
  59028. }
  59029. declare module BABYLON {
  59030. /**
  59031. * The GrainPostProcess adds noise to the image at mid luminance levels
  59032. */
  59033. export class GrainPostProcess extends PostProcess {
  59034. /**
  59035. * The intensity of the grain added (default: 30)
  59036. */
  59037. intensity: number;
  59038. /**
  59039. * If the grain should be randomized on every frame
  59040. */
  59041. animated: boolean;
  59042. /**
  59043. * Creates a new instance of @see GrainPostProcess
  59044. * @param name The name of the effect.
  59045. * @param options The required width/height ratio to downsize to before computing the render pass.
  59046. * @param camera The camera to apply the render pass to.
  59047. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59048. * @param engine The engine which the post process will be applied. (default: current engine)
  59049. * @param reusable If the post process can be reused on the same frame. (default: false)
  59050. * @param textureType Type of textures used when performing the post process. (default: 0)
  59051. * @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)
  59052. */
  59053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59054. }
  59055. }
  59056. declare module BABYLON {
  59057. /** @hidden */
  59058. export var highlightsPixelShader: {
  59059. name: string;
  59060. shader: string;
  59061. };
  59062. }
  59063. declare module BABYLON {
  59064. /**
  59065. * Extracts highlights from the image
  59066. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59067. */
  59068. export class HighlightsPostProcess extends PostProcess {
  59069. /**
  59070. * Extracts highlights from the image
  59071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59072. * @param name The name of the effect.
  59073. * @param options The required width/height ratio to downsize to before computing the render pass.
  59074. * @param camera The camera to apply the render pass to.
  59075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59076. * @param engine The engine which the post process will be applied. (default: current engine)
  59077. * @param reusable If the post process can be reused on the same frame. (default: false)
  59078. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59079. */
  59080. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59081. }
  59082. }
  59083. declare module BABYLON {
  59084. /** @hidden */
  59085. export var mrtFragmentDeclaration: {
  59086. name: string;
  59087. shader: string;
  59088. };
  59089. }
  59090. declare module BABYLON {
  59091. /** @hidden */
  59092. export var geometryPixelShader: {
  59093. name: string;
  59094. shader: string;
  59095. };
  59096. }
  59097. declare module BABYLON {
  59098. /** @hidden */
  59099. export var geometryVertexShader: {
  59100. name: string;
  59101. shader: string;
  59102. };
  59103. }
  59104. declare module BABYLON {
  59105. /** @hidden */
  59106. interface ISavedTransformationMatrix {
  59107. world: Matrix;
  59108. viewProjection: Matrix;
  59109. }
  59110. /**
  59111. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59112. */
  59113. export class GeometryBufferRenderer {
  59114. /**
  59115. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59116. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59117. */
  59118. static readonly POSITION_TEXTURE_TYPE: number;
  59119. /**
  59120. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59121. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59122. */
  59123. static readonly VELOCITY_TEXTURE_TYPE: number;
  59124. /**
  59125. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59126. * in order to compute objects velocities when enableVelocity is set to "true"
  59127. * @hidden
  59128. */
  59129. _previousTransformationMatrices: {
  59130. [index: number]: ISavedTransformationMatrix;
  59131. };
  59132. /**
  59133. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59134. * in order to compute objects velocities when enableVelocity is set to "true"
  59135. * @hidden
  59136. */
  59137. _previousBonesTransformationMatrices: {
  59138. [index: number]: Float32Array;
  59139. };
  59140. /**
  59141. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59142. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59143. */
  59144. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59145. private _scene;
  59146. private _multiRenderTarget;
  59147. private _ratio;
  59148. private _enablePosition;
  59149. private _enableVelocity;
  59150. private _positionIndex;
  59151. private _velocityIndex;
  59152. protected _effect: Effect;
  59153. protected _cachedDefines: string;
  59154. /**
  59155. * Set the render list (meshes to be rendered) used in the G buffer.
  59156. */
  59157. renderList: Mesh[];
  59158. /**
  59159. * Gets wether or not G buffer are supported by the running hardware.
  59160. * This requires draw buffer supports
  59161. */
  59162. readonly isSupported: boolean;
  59163. /**
  59164. * Returns the index of the given texture type in the G-Buffer textures array
  59165. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59166. * @returns the index of the given texture type in the G-Buffer textures array
  59167. */
  59168. getTextureIndex(textureType: number): number;
  59169. /**
  59170. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59171. */
  59172. /**
  59173. * Sets whether or not objects positions are enabled for the G buffer.
  59174. */
  59175. enablePosition: boolean;
  59176. /**
  59177. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59178. */
  59179. /**
  59180. * Sets wether or not objects velocities are enabled for the G buffer.
  59181. */
  59182. enableVelocity: boolean;
  59183. /**
  59184. * Gets the scene associated with the buffer.
  59185. */
  59186. readonly scene: Scene;
  59187. /**
  59188. * Gets the ratio used by the buffer during its creation.
  59189. * How big is the buffer related to the main canvas.
  59190. */
  59191. readonly ratio: number;
  59192. /** @hidden */
  59193. static _SceneComponentInitialization: (scene: Scene) => void;
  59194. /**
  59195. * Creates a new G Buffer for the scene
  59196. * @param scene The scene the buffer belongs to
  59197. * @param ratio How big is the buffer related to the main canvas.
  59198. */
  59199. constructor(scene: Scene, ratio?: number);
  59200. /**
  59201. * Checks wether everything is ready to render a submesh to the G buffer.
  59202. * @param subMesh the submesh to check readiness for
  59203. * @param useInstances is the mesh drawn using instance or not
  59204. * @returns true if ready otherwise false
  59205. */
  59206. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59207. /**
  59208. * Gets the current underlying G Buffer.
  59209. * @returns the buffer
  59210. */
  59211. getGBuffer(): MultiRenderTarget;
  59212. /**
  59213. * Gets the number of samples used to render the buffer (anti aliasing).
  59214. */
  59215. /**
  59216. * Sets the number of samples used to render the buffer (anti aliasing).
  59217. */
  59218. samples: number;
  59219. /**
  59220. * Disposes the renderer and frees up associated resources.
  59221. */
  59222. dispose(): void;
  59223. protected _createRenderTargets(): void;
  59224. private _copyBonesTransformationMatrices;
  59225. }
  59226. }
  59227. declare module BABYLON {
  59228. interface Scene {
  59229. /** @hidden (Backing field) */
  59230. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59231. /**
  59232. * Gets or Sets the current geometry buffer associated to the scene.
  59233. */
  59234. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59235. /**
  59236. * Enables a GeometryBufferRender and associates it with the scene
  59237. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59238. * @returns the GeometryBufferRenderer
  59239. */
  59240. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59241. /**
  59242. * Disables the GeometryBufferRender associated with the scene
  59243. */
  59244. disableGeometryBufferRenderer(): void;
  59245. }
  59246. /**
  59247. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59248. * in several rendering techniques.
  59249. */
  59250. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59251. /**
  59252. * The component name helpful to identify the component in the list of scene components.
  59253. */
  59254. readonly name: string;
  59255. /**
  59256. * The scene the component belongs to.
  59257. */
  59258. scene: Scene;
  59259. /**
  59260. * Creates a new instance of the component for the given scene
  59261. * @param scene Defines the scene to register the component in
  59262. */
  59263. constructor(scene: Scene);
  59264. /**
  59265. * Registers the component in a given scene
  59266. */
  59267. register(): void;
  59268. /**
  59269. * Rebuilds the elements related to this component in case of
  59270. * context lost for instance.
  59271. */
  59272. rebuild(): void;
  59273. /**
  59274. * Disposes the component and the associated ressources
  59275. */
  59276. dispose(): void;
  59277. private _gatherRenderTargets;
  59278. }
  59279. }
  59280. declare module BABYLON {
  59281. /** @hidden */
  59282. export var motionBlurPixelShader: {
  59283. name: string;
  59284. shader: string;
  59285. };
  59286. }
  59287. declare module BABYLON {
  59288. /**
  59289. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59290. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59291. * As an example, all you have to do is to create the post-process:
  59292. * var mb = new BABYLON.MotionBlurPostProcess(
  59293. * 'mb', // The name of the effect.
  59294. * scene, // The scene containing the objects to blur according to their velocity.
  59295. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59296. * camera // The camera to apply the render pass to.
  59297. * );
  59298. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59299. */
  59300. export class MotionBlurPostProcess extends PostProcess {
  59301. /**
  59302. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59303. */
  59304. motionStrength: number;
  59305. /**
  59306. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59307. */
  59308. /**
  59309. * Sets the number of iterations to be used for motion blur quality
  59310. */
  59311. motionBlurSamples: number;
  59312. private _motionBlurSamples;
  59313. private _geometryBufferRenderer;
  59314. /**
  59315. * Creates a new instance MotionBlurPostProcess
  59316. * @param name The name of the effect.
  59317. * @param scene The scene containing the objects to blur according to their velocity.
  59318. * @param options The required width/height ratio to downsize to before computing the render pass.
  59319. * @param camera The camera to apply the render pass to.
  59320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59321. * @param engine The engine which the post process will be applied. (default: current engine)
  59322. * @param reusable If the post process can be reused on the same frame. (default: false)
  59323. * @param textureType Type of textures used when performing the post process. (default: 0)
  59324. * @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)
  59325. */
  59326. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59327. /**
  59328. * Excludes the given skinned mesh from computing bones velocities.
  59329. * 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.
  59330. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59331. */
  59332. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59333. /**
  59334. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59335. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59336. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59337. */
  59338. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59339. /**
  59340. * Disposes the post process.
  59341. * @param camera The camera to dispose the post process on.
  59342. */
  59343. dispose(camera?: Camera): void;
  59344. }
  59345. }
  59346. declare module BABYLON {
  59347. /** @hidden */
  59348. export var refractionPixelShader: {
  59349. name: string;
  59350. shader: string;
  59351. };
  59352. }
  59353. declare module BABYLON {
  59354. /**
  59355. * Post process which applies a refractin texture
  59356. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59357. */
  59358. export class RefractionPostProcess extends PostProcess {
  59359. /** the base color of the refraction (used to taint the rendering) */
  59360. color: Color3;
  59361. /** simulated refraction depth */
  59362. depth: number;
  59363. /** the coefficient of the base color (0 to remove base color tainting) */
  59364. colorLevel: number;
  59365. private _refTexture;
  59366. private _ownRefractionTexture;
  59367. /**
  59368. * Gets or sets the refraction texture
  59369. * Please note that you are responsible for disposing the texture if you set it manually
  59370. */
  59371. refractionTexture: Texture;
  59372. /**
  59373. * Initializes the RefractionPostProcess
  59374. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59375. * @param name The name of the effect.
  59376. * @param refractionTextureUrl Url of the refraction texture to use
  59377. * @param color the base color of the refraction (used to taint the rendering)
  59378. * @param depth simulated refraction depth
  59379. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  59380. * @param camera The camera to apply the render pass to.
  59381. * @param options The required width/height ratio to downsize to before computing the render pass.
  59382. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59383. * @param engine The engine which the post process will be applied. (default: current engine)
  59384. * @param reusable If the post process can be reused on the same frame. (default: false)
  59385. */
  59386. constructor(name: string, refractionTextureUrl: string,
  59387. /** the base color of the refraction (used to taint the rendering) */
  59388. color: Color3,
  59389. /** simulated refraction depth */
  59390. depth: number,
  59391. /** the coefficient of the base color (0 to remove base color tainting) */
  59392. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59393. /**
  59394. * Disposes of the post process
  59395. * @param camera Camera to dispose post process on
  59396. */
  59397. dispose(camera: Camera): void;
  59398. }
  59399. }
  59400. declare module BABYLON {
  59401. /** @hidden */
  59402. export var sharpenPixelShader: {
  59403. name: string;
  59404. shader: string;
  59405. };
  59406. }
  59407. declare module BABYLON {
  59408. /**
  59409. * The SharpenPostProcess applies a sharpen kernel to every pixel
  59410. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59411. */
  59412. export class SharpenPostProcess extends PostProcess {
  59413. /**
  59414. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  59415. */
  59416. colorAmount: number;
  59417. /**
  59418. * How much sharpness should be applied (default: 0.3)
  59419. */
  59420. edgeAmount: number;
  59421. /**
  59422. * Creates a new instance ConvolutionPostProcess
  59423. * @param name The name of the effect.
  59424. * @param options The required width/height ratio to downsize to before computing the render pass.
  59425. * @param camera The camera to apply the render pass to.
  59426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59427. * @param engine The engine which the post process will be applied. (default: current engine)
  59428. * @param reusable If the post process can be reused on the same frame. (default: false)
  59429. * @param textureType Type of textures used when performing the post process. (default: 0)
  59430. * @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)
  59431. */
  59432. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59433. }
  59434. }
  59435. declare module BABYLON {
  59436. /**
  59437. * PostProcessRenderPipeline
  59438. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59439. */
  59440. export class PostProcessRenderPipeline {
  59441. private engine;
  59442. private _renderEffects;
  59443. private _renderEffectsForIsolatedPass;
  59444. /**
  59445. * List of inspectable custom properties (used by the Inspector)
  59446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  59447. */
  59448. inspectableCustomProperties: IInspectable[];
  59449. /**
  59450. * @hidden
  59451. */
  59452. protected _cameras: Camera[];
  59453. /** @hidden */
  59454. _name: string;
  59455. /**
  59456. * Gets pipeline name
  59457. */
  59458. readonly name: string;
  59459. /**
  59460. * Initializes a PostProcessRenderPipeline
  59461. * @param engine engine to add the pipeline to
  59462. * @param name name of the pipeline
  59463. */
  59464. constructor(engine: Engine, name: string);
  59465. /**
  59466. * Gets the class name
  59467. * @returns "PostProcessRenderPipeline"
  59468. */
  59469. getClassName(): string;
  59470. /**
  59471. * If all the render effects in the pipeline are supported
  59472. */
  59473. readonly isSupported: boolean;
  59474. /**
  59475. * Adds an effect to the pipeline
  59476. * @param renderEffect the effect to add
  59477. */
  59478. addEffect(renderEffect: PostProcessRenderEffect): void;
  59479. /** @hidden */
  59480. _rebuild(): void;
  59481. /** @hidden */
  59482. _enableEffect(renderEffectName: string, cameras: Camera): void;
  59483. /** @hidden */
  59484. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59485. /** @hidden */
  59486. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59487. /** @hidden */
  59488. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59489. /** @hidden */
  59490. _attachCameras(cameras: Camera, unique: boolean): void;
  59491. /** @hidden */
  59492. _attachCameras(cameras: Camera[], unique: boolean): void;
  59493. /** @hidden */
  59494. _detachCameras(cameras: Camera): void;
  59495. /** @hidden */
  59496. _detachCameras(cameras: Nullable<Camera[]>): void;
  59497. /** @hidden */
  59498. _update(): void;
  59499. /** @hidden */
  59500. _reset(): void;
  59501. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59502. /**
  59503. * Disposes of the pipeline
  59504. */
  59505. dispose(): void;
  59506. }
  59507. }
  59508. declare module BABYLON {
  59509. /**
  59510. * PostProcessRenderPipelineManager class
  59511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59512. */
  59513. export class PostProcessRenderPipelineManager {
  59514. private _renderPipelines;
  59515. /**
  59516. * Initializes a PostProcessRenderPipelineManager
  59517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59518. */
  59519. constructor();
  59520. /**
  59521. * Gets the list of supported render pipelines
  59522. */
  59523. readonly supportedPipelines: PostProcessRenderPipeline[];
  59524. /**
  59525. * Adds a pipeline to the manager
  59526. * @param renderPipeline The pipeline to add
  59527. */
  59528. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59529. /**
  59530. * Attaches a camera to the pipeline
  59531. * @param renderPipelineName The name of the pipeline to attach to
  59532. * @param cameras the camera to attach
  59533. * @param unique if the camera can be attached multiple times to the pipeline
  59534. */
  59535. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59536. /**
  59537. * Detaches a camera from the pipeline
  59538. * @param renderPipelineName The name of the pipeline to detach from
  59539. * @param cameras the camera to detach
  59540. */
  59541. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59542. /**
  59543. * Enables an effect by name on a pipeline
  59544. * @param renderPipelineName the name of the pipeline to enable the effect in
  59545. * @param renderEffectName the name of the effect to enable
  59546. * @param cameras the cameras that the effect should be enabled on
  59547. */
  59548. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59549. /**
  59550. * Disables an effect by name on a pipeline
  59551. * @param renderPipelineName the name of the pipeline to disable the effect in
  59552. * @param renderEffectName the name of the effect to disable
  59553. * @param cameras the cameras that the effect should be disabled on
  59554. */
  59555. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59556. /**
  59557. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59558. */
  59559. update(): void;
  59560. /** @hidden */
  59561. _rebuild(): void;
  59562. /**
  59563. * Disposes of the manager and pipelines
  59564. */
  59565. dispose(): void;
  59566. }
  59567. }
  59568. declare module BABYLON {
  59569. interface Scene {
  59570. /** @hidden (Backing field) */
  59571. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59572. /**
  59573. * Gets the postprocess render pipeline manager
  59574. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59575. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59576. */
  59577. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59578. }
  59579. /**
  59580. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59581. */
  59582. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59583. /**
  59584. * The component name helpfull to identify the component in the list of scene components.
  59585. */
  59586. readonly name: string;
  59587. /**
  59588. * The scene the component belongs to.
  59589. */
  59590. scene: Scene;
  59591. /**
  59592. * Creates a new instance of the component for the given scene
  59593. * @param scene Defines the scene to register the component in
  59594. */
  59595. constructor(scene: Scene);
  59596. /**
  59597. * Registers the component in a given scene
  59598. */
  59599. register(): void;
  59600. /**
  59601. * Rebuilds the elements related to this component in case of
  59602. * context lost for instance.
  59603. */
  59604. rebuild(): void;
  59605. /**
  59606. * Disposes the component and the associated ressources
  59607. */
  59608. dispose(): void;
  59609. private _gatherRenderTargets;
  59610. }
  59611. }
  59612. declare module BABYLON {
  59613. /**
  59614. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59615. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59616. */
  59617. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59618. private _scene;
  59619. private _camerasToBeAttached;
  59620. /**
  59621. * ID of the sharpen post process,
  59622. */
  59623. private readonly SharpenPostProcessId;
  59624. /**
  59625. * @ignore
  59626. * ID of the image processing post process;
  59627. */
  59628. readonly ImageProcessingPostProcessId: string;
  59629. /**
  59630. * @ignore
  59631. * ID of the Fast Approximate Anti-Aliasing post process;
  59632. */
  59633. readonly FxaaPostProcessId: string;
  59634. /**
  59635. * ID of the chromatic aberration post process,
  59636. */
  59637. private readonly ChromaticAberrationPostProcessId;
  59638. /**
  59639. * ID of the grain post process
  59640. */
  59641. private readonly GrainPostProcessId;
  59642. /**
  59643. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59644. */
  59645. sharpen: SharpenPostProcess;
  59646. private _sharpenEffect;
  59647. private bloom;
  59648. /**
  59649. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59650. */
  59651. depthOfField: DepthOfFieldEffect;
  59652. /**
  59653. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59654. */
  59655. fxaa: FxaaPostProcess;
  59656. /**
  59657. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59658. */
  59659. imageProcessing: ImageProcessingPostProcess;
  59660. /**
  59661. * Chromatic aberration post process which will shift rgb colors in the image
  59662. */
  59663. chromaticAberration: ChromaticAberrationPostProcess;
  59664. private _chromaticAberrationEffect;
  59665. /**
  59666. * Grain post process which add noise to the image
  59667. */
  59668. grain: GrainPostProcess;
  59669. private _grainEffect;
  59670. /**
  59671. * Glow post process which adds a glow to emissive areas of the image
  59672. */
  59673. private _glowLayer;
  59674. /**
  59675. * Animations which can be used to tweak settings over a period of time
  59676. */
  59677. animations: Animation[];
  59678. private _imageProcessingConfigurationObserver;
  59679. private _sharpenEnabled;
  59680. private _bloomEnabled;
  59681. private _depthOfFieldEnabled;
  59682. private _depthOfFieldBlurLevel;
  59683. private _fxaaEnabled;
  59684. private _imageProcessingEnabled;
  59685. private _defaultPipelineTextureType;
  59686. private _bloomScale;
  59687. private _chromaticAberrationEnabled;
  59688. private _grainEnabled;
  59689. private _buildAllowed;
  59690. /**
  59691. * Gets active scene
  59692. */
  59693. readonly scene: Scene;
  59694. /**
  59695. * Enable or disable the sharpen process from the pipeline
  59696. */
  59697. sharpenEnabled: boolean;
  59698. private _resizeObserver;
  59699. private _hardwareScaleLevel;
  59700. private _bloomKernel;
  59701. /**
  59702. * Specifies the size of the bloom blur kernel, relative to the final output size
  59703. */
  59704. bloomKernel: number;
  59705. /**
  59706. * Specifies the weight of the bloom in the final rendering
  59707. */
  59708. private _bloomWeight;
  59709. /**
  59710. * Specifies the luma threshold for the area that will be blurred by the bloom
  59711. */
  59712. private _bloomThreshold;
  59713. private _hdr;
  59714. /**
  59715. * The strength of the bloom.
  59716. */
  59717. bloomWeight: number;
  59718. /**
  59719. * The strength of the bloom.
  59720. */
  59721. bloomThreshold: number;
  59722. /**
  59723. * The scale of the bloom, lower value will provide better performance.
  59724. */
  59725. bloomScale: number;
  59726. /**
  59727. * Enable or disable the bloom from the pipeline
  59728. */
  59729. bloomEnabled: boolean;
  59730. private _rebuildBloom;
  59731. /**
  59732. * If the depth of field is enabled.
  59733. */
  59734. depthOfFieldEnabled: boolean;
  59735. /**
  59736. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59737. */
  59738. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59739. /**
  59740. * If the anti aliasing is enabled.
  59741. */
  59742. fxaaEnabled: boolean;
  59743. private _samples;
  59744. /**
  59745. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59746. */
  59747. samples: number;
  59748. /**
  59749. * If image processing is enabled.
  59750. */
  59751. imageProcessingEnabled: boolean;
  59752. /**
  59753. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59754. */
  59755. glowLayerEnabled: boolean;
  59756. /**
  59757. * Gets the glow layer (or null if not defined)
  59758. */
  59759. readonly glowLayer: Nullable<GlowLayer>;
  59760. /**
  59761. * Enable or disable the chromaticAberration process from the pipeline
  59762. */
  59763. chromaticAberrationEnabled: boolean;
  59764. /**
  59765. * Enable or disable the grain process from the pipeline
  59766. */
  59767. grainEnabled: boolean;
  59768. /**
  59769. * @constructor
  59770. * @param name - The rendering pipeline name (default: "")
  59771. * @param hdr - If high dynamic range textures should be used (default: true)
  59772. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59773. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59774. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59775. */
  59776. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59777. /**
  59778. * Get the class name
  59779. * @returns "DefaultRenderingPipeline"
  59780. */
  59781. getClassName(): string;
  59782. /**
  59783. * Force the compilation of the entire pipeline.
  59784. */
  59785. prepare(): void;
  59786. private _hasCleared;
  59787. private _prevPostProcess;
  59788. private _prevPrevPostProcess;
  59789. private _setAutoClearAndTextureSharing;
  59790. private _depthOfFieldSceneObserver;
  59791. private _buildPipeline;
  59792. private _disposePostProcesses;
  59793. /**
  59794. * Adds a camera to the pipeline
  59795. * @param camera the camera to be added
  59796. */
  59797. addCamera(camera: Camera): void;
  59798. /**
  59799. * Removes a camera from the pipeline
  59800. * @param camera the camera to remove
  59801. */
  59802. removeCamera(camera: Camera): void;
  59803. /**
  59804. * Dispose of the pipeline and stop all post processes
  59805. */
  59806. dispose(): void;
  59807. /**
  59808. * Serialize the rendering pipeline (Used when exporting)
  59809. * @returns the serialized object
  59810. */
  59811. serialize(): any;
  59812. /**
  59813. * Parse the serialized pipeline
  59814. * @param source Source pipeline.
  59815. * @param scene The scene to load the pipeline to.
  59816. * @param rootUrl The URL of the serialized pipeline.
  59817. * @returns An instantiated pipeline from the serialized object.
  59818. */
  59819. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59820. }
  59821. }
  59822. declare module BABYLON {
  59823. /** @hidden */
  59824. export var lensHighlightsPixelShader: {
  59825. name: string;
  59826. shader: string;
  59827. };
  59828. }
  59829. declare module BABYLON {
  59830. /** @hidden */
  59831. export var depthOfFieldPixelShader: {
  59832. name: string;
  59833. shader: string;
  59834. };
  59835. }
  59836. declare module BABYLON {
  59837. /**
  59838. * BABYLON.JS Chromatic Aberration GLSL Shader
  59839. * Author: Olivier Guyot
  59840. * Separates very slightly R, G and B colors on the edges of the screen
  59841. * Inspired by Francois Tarlier & Martins Upitis
  59842. */
  59843. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59844. /**
  59845. * @ignore
  59846. * The chromatic aberration PostProcess id in the pipeline
  59847. */
  59848. LensChromaticAberrationEffect: string;
  59849. /**
  59850. * @ignore
  59851. * The highlights enhancing PostProcess id in the pipeline
  59852. */
  59853. HighlightsEnhancingEffect: string;
  59854. /**
  59855. * @ignore
  59856. * The depth-of-field PostProcess id in the pipeline
  59857. */
  59858. LensDepthOfFieldEffect: string;
  59859. private _scene;
  59860. private _depthTexture;
  59861. private _grainTexture;
  59862. private _chromaticAberrationPostProcess;
  59863. private _highlightsPostProcess;
  59864. private _depthOfFieldPostProcess;
  59865. private _edgeBlur;
  59866. private _grainAmount;
  59867. private _chromaticAberration;
  59868. private _distortion;
  59869. private _highlightsGain;
  59870. private _highlightsThreshold;
  59871. private _dofDistance;
  59872. private _dofAperture;
  59873. private _dofDarken;
  59874. private _dofPentagon;
  59875. private _blurNoise;
  59876. /**
  59877. * @constructor
  59878. *
  59879. * Effect parameters are as follow:
  59880. * {
  59881. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59882. * edge_blur: number; // from 0 to x (1 for realism)
  59883. * distortion: number; // from 0 to x (1 for realism)
  59884. * grain_amount: number; // from 0 to 1
  59885. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59886. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59887. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59888. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59889. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59890. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59891. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59892. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59893. * }
  59894. * Note: if an effect parameter is unset, effect is disabled
  59895. *
  59896. * @param name The rendering pipeline name
  59897. * @param parameters - An object containing all parameters (see above)
  59898. * @param scene The scene linked to this pipeline
  59899. * @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)
  59900. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59901. */
  59902. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59903. /**
  59904. * Get the class name
  59905. * @returns "LensRenderingPipeline"
  59906. */
  59907. getClassName(): string;
  59908. /**
  59909. * Gets associated scene
  59910. */
  59911. readonly scene: Scene;
  59912. /**
  59913. * Gets or sets the edge blur
  59914. */
  59915. edgeBlur: number;
  59916. /**
  59917. * Gets or sets the grain amount
  59918. */
  59919. grainAmount: number;
  59920. /**
  59921. * Gets or sets the chromatic aberration amount
  59922. */
  59923. chromaticAberration: number;
  59924. /**
  59925. * Gets or sets the depth of field aperture
  59926. */
  59927. dofAperture: number;
  59928. /**
  59929. * Gets or sets the edge distortion
  59930. */
  59931. edgeDistortion: number;
  59932. /**
  59933. * Gets or sets the depth of field distortion
  59934. */
  59935. dofDistortion: number;
  59936. /**
  59937. * Gets or sets the darken out of focus amount
  59938. */
  59939. darkenOutOfFocus: number;
  59940. /**
  59941. * Gets or sets a boolean indicating if blur noise is enabled
  59942. */
  59943. blurNoise: boolean;
  59944. /**
  59945. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59946. */
  59947. pentagonBokeh: boolean;
  59948. /**
  59949. * Gets or sets the highlight grain amount
  59950. */
  59951. highlightsGain: number;
  59952. /**
  59953. * Gets or sets the highlight threshold
  59954. */
  59955. highlightsThreshold: number;
  59956. /**
  59957. * Sets the amount of blur at the edges
  59958. * @param amount blur amount
  59959. */
  59960. setEdgeBlur(amount: number): void;
  59961. /**
  59962. * Sets edge blur to 0
  59963. */
  59964. disableEdgeBlur(): void;
  59965. /**
  59966. * Sets the amout of grain
  59967. * @param amount Amount of grain
  59968. */
  59969. setGrainAmount(amount: number): void;
  59970. /**
  59971. * Set grain amount to 0
  59972. */
  59973. disableGrain(): void;
  59974. /**
  59975. * Sets the chromatic aberration amount
  59976. * @param amount amount of chromatic aberration
  59977. */
  59978. setChromaticAberration(amount: number): void;
  59979. /**
  59980. * Sets chromatic aberration amount to 0
  59981. */
  59982. disableChromaticAberration(): void;
  59983. /**
  59984. * Sets the EdgeDistortion amount
  59985. * @param amount amount of EdgeDistortion
  59986. */
  59987. setEdgeDistortion(amount: number): void;
  59988. /**
  59989. * Sets edge distortion to 0
  59990. */
  59991. disableEdgeDistortion(): void;
  59992. /**
  59993. * Sets the FocusDistance amount
  59994. * @param amount amount of FocusDistance
  59995. */
  59996. setFocusDistance(amount: number): void;
  59997. /**
  59998. * Disables depth of field
  59999. */
  60000. disableDepthOfField(): void;
  60001. /**
  60002. * Sets the Aperture amount
  60003. * @param amount amount of Aperture
  60004. */
  60005. setAperture(amount: number): void;
  60006. /**
  60007. * Sets the DarkenOutOfFocus amount
  60008. * @param amount amount of DarkenOutOfFocus
  60009. */
  60010. setDarkenOutOfFocus(amount: number): void;
  60011. private _pentagonBokehIsEnabled;
  60012. /**
  60013. * Creates a pentagon bokeh effect
  60014. */
  60015. enablePentagonBokeh(): void;
  60016. /**
  60017. * Disables the pentagon bokeh effect
  60018. */
  60019. disablePentagonBokeh(): void;
  60020. /**
  60021. * Enables noise blur
  60022. */
  60023. enableNoiseBlur(): void;
  60024. /**
  60025. * Disables noise blur
  60026. */
  60027. disableNoiseBlur(): void;
  60028. /**
  60029. * Sets the HighlightsGain amount
  60030. * @param amount amount of HighlightsGain
  60031. */
  60032. setHighlightsGain(amount: number): void;
  60033. /**
  60034. * Sets the HighlightsThreshold amount
  60035. * @param amount amount of HighlightsThreshold
  60036. */
  60037. setHighlightsThreshold(amount: number): void;
  60038. /**
  60039. * Disables highlights
  60040. */
  60041. disableHighlights(): void;
  60042. /**
  60043. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60044. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60045. */
  60046. dispose(disableDepthRender?: boolean): void;
  60047. private _createChromaticAberrationPostProcess;
  60048. private _createHighlightsPostProcess;
  60049. private _createDepthOfFieldPostProcess;
  60050. private _createGrainTexture;
  60051. }
  60052. }
  60053. declare module BABYLON {
  60054. /** @hidden */
  60055. export var ssao2PixelShader: {
  60056. name: string;
  60057. shader: string;
  60058. };
  60059. }
  60060. declare module BABYLON {
  60061. /** @hidden */
  60062. export var ssaoCombinePixelShader: {
  60063. name: string;
  60064. shader: string;
  60065. };
  60066. }
  60067. declare module BABYLON {
  60068. /**
  60069. * Render pipeline to produce ssao effect
  60070. */
  60071. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60072. /**
  60073. * @ignore
  60074. * The PassPostProcess id in the pipeline that contains the original scene color
  60075. */
  60076. SSAOOriginalSceneColorEffect: string;
  60077. /**
  60078. * @ignore
  60079. * The SSAO PostProcess id in the pipeline
  60080. */
  60081. SSAORenderEffect: string;
  60082. /**
  60083. * @ignore
  60084. * The horizontal blur PostProcess id in the pipeline
  60085. */
  60086. SSAOBlurHRenderEffect: string;
  60087. /**
  60088. * @ignore
  60089. * The vertical blur PostProcess id in the pipeline
  60090. */
  60091. SSAOBlurVRenderEffect: string;
  60092. /**
  60093. * @ignore
  60094. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60095. */
  60096. SSAOCombineRenderEffect: string;
  60097. /**
  60098. * The output strength of the SSAO post-process. Default value is 1.0.
  60099. */
  60100. totalStrength: number;
  60101. /**
  60102. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60103. */
  60104. maxZ: number;
  60105. /**
  60106. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60107. */
  60108. minZAspect: number;
  60109. private _samples;
  60110. /**
  60111. * Number of samples used for the SSAO calculations. Default value is 8
  60112. */
  60113. samples: number;
  60114. private _textureSamples;
  60115. /**
  60116. * Number of samples to use for antialiasing
  60117. */
  60118. textureSamples: number;
  60119. /**
  60120. * Ratio object used for SSAO ratio and blur ratio
  60121. */
  60122. private _ratio;
  60123. /**
  60124. * Dynamically generated sphere sampler.
  60125. */
  60126. private _sampleSphere;
  60127. /**
  60128. * Blur filter offsets
  60129. */
  60130. private _samplerOffsets;
  60131. private _expensiveBlur;
  60132. /**
  60133. * If bilateral blur should be used
  60134. */
  60135. expensiveBlur: boolean;
  60136. /**
  60137. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60138. */
  60139. radius: number;
  60140. /**
  60141. * The base color of the SSAO post-process
  60142. * The final result is "base + ssao" between [0, 1]
  60143. */
  60144. base: number;
  60145. /**
  60146. * Support test.
  60147. */
  60148. static readonly IsSupported: boolean;
  60149. private _scene;
  60150. private _depthTexture;
  60151. private _normalTexture;
  60152. private _randomTexture;
  60153. private _originalColorPostProcess;
  60154. private _ssaoPostProcess;
  60155. private _blurHPostProcess;
  60156. private _blurVPostProcess;
  60157. private _ssaoCombinePostProcess;
  60158. private _firstUpdate;
  60159. /**
  60160. * Gets active scene
  60161. */
  60162. readonly scene: Scene;
  60163. /**
  60164. * @constructor
  60165. * @param name The rendering pipeline name
  60166. * @param scene The scene linked to this pipeline
  60167. * @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 }
  60168. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60169. */
  60170. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60171. /**
  60172. * Get the class name
  60173. * @returns "SSAO2RenderingPipeline"
  60174. */
  60175. getClassName(): string;
  60176. /**
  60177. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60178. */
  60179. dispose(disableGeometryBufferRenderer?: boolean): void;
  60180. private _createBlurPostProcess;
  60181. /** @hidden */
  60182. _rebuild(): void;
  60183. private _bits;
  60184. private _radicalInverse_VdC;
  60185. private _hammersley;
  60186. private _hemisphereSample_uniform;
  60187. private _generateHemisphere;
  60188. private _createSSAOPostProcess;
  60189. private _createSSAOCombinePostProcess;
  60190. private _createRandomTexture;
  60191. /**
  60192. * Serialize the rendering pipeline (Used when exporting)
  60193. * @returns the serialized object
  60194. */
  60195. serialize(): any;
  60196. /**
  60197. * Parse the serialized pipeline
  60198. * @param source Source pipeline.
  60199. * @param scene The scene to load the pipeline to.
  60200. * @param rootUrl The URL of the serialized pipeline.
  60201. * @returns An instantiated pipeline from the serialized object.
  60202. */
  60203. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60204. }
  60205. }
  60206. declare module BABYLON {
  60207. /** @hidden */
  60208. export var ssaoPixelShader: {
  60209. name: string;
  60210. shader: string;
  60211. };
  60212. }
  60213. declare module BABYLON {
  60214. /**
  60215. * Render pipeline to produce ssao effect
  60216. */
  60217. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60218. /**
  60219. * @ignore
  60220. * The PassPostProcess id in the pipeline that contains the original scene color
  60221. */
  60222. SSAOOriginalSceneColorEffect: string;
  60223. /**
  60224. * @ignore
  60225. * The SSAO PostProcess id in the pipeline
  60226. */
  60227. SSAORenderEffect: string;
  60228. /**
  60229. * @ignore
  60230. * The horizontal blur PostProcess id in the pipeline
  60231. */
  60232. SSAOBlurHRenderEffect: string;
  60233. /**
  60234. * @ignore
  60235. * The vertical blur PostProcess id in the pipeline
  60236. */
  60237. SSAOBlurVRenderEffect: string;
  60238. /**
  60239. * @ignore
  60240. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60241. */
  60242. SSAOCombineRenderEffect: string;
  60243. /**
  60244. * The output strength of the SSAO post-process. Default value is 1.0.
  60245. */
  60246. totalStrength: number;
  60247. /**
  60248. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60249. */
  60250. radius: number;
  60251. /**
  60252. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60253. * Must not be equal to fallOff and superior to fallOff.
  60254. * Default value is 0.0075
  60255. */
  60256. area: number;
  60257. /**
  60258. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60259. * Must not be equal to area and inferior to area.
  60260. * Default value is 0.000001
  60261. */
  60262. fallOff: number;
  60263. /**
  60264. * The base color of the SSAO post-process
  60265. * The final result is "base + ssao" between [0, 1]
  60266. */
  60267. base: number;
  60268. private _scene;
  60269. private _depthTexture;
  60270. private _randomTexture;
  60271. private _originalColorPostProcess;
  60272. private _ssaoPostProcess;
  60273. private _blurHPostProcess;
  60274. private _blurVPostProcess;
  60275. private _ssaoCombinePostProcess;
  60276. private _firstUpdate;
  60277. /**
  60278. * Gets active scene
  60279. */
  60280. readonly scene: Scene;
  60281. /**
  60282. * @constructor
  60283. * @param name - The rendering pipeline name
  60284. * @param scene - The scene linked to this pipeline
  60285. * @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 }
  60286. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60287. */
  60288. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60289. /**
  60290. * Get the class name
  60291. * @returns "SSAORenderingPipeline"
  60292. */
  60293. getClassName(): string;
  60294. /**
  60295. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60296. */
  60297. dispose(disableDepthRender?: boolean): void;
  60298. private _createBlurPostProcess;
  60299. /** @hidden */
  60300. _rebuild(): void;
  60301. private _createSSAOPostProcess;
  60302. private _createSSAOCombinePostProcess;
  60303. private _createRandomTexture;
  60304. }
  60305. }
  60306. declare module BABYLON {
  60307. /** @hidden */
  60308. export var standardPixelShader: {
  60309. name: string;
  60310. shader: string;
  60311. };
  60312. }
  60313. declare module BABYLON {
  60314. /**
  60315. * Standard rendering pipeline
  60316. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60317. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  60318. */
  60319. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60320. /**
  60321. * Public members
  60322. */
  60323. /**
  60324. * Post-process which contains the original scene color before the pipeline applies all the effects
  60325. */
  60326. originalPostProcess: Nullable<PostProcess>;
  60327. /**
  60328. * Post-process used to down scale an image x4
  60329. */
  60330. downSampleX4PostProcess: Nullable<PostProcess>;
  60331. /**
  60332. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  60333. */
  60334. brightPassPostProcess: Nullable<PostProcess>;
  60335. /**
  60336. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  60337. */
  60338. blurHPostProcesses: PostProcess[];
  60339. /**
  60340. * Post-process array storing all the vertical blur post-processes used by the pipeline
  60341. */
  60342. blurVPostProcesses: PostProcess[];
  60343. /**
  60344. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  60345. */
  60346. textureAdderPostProcess: Nullable<PostProcess>;
  60347. /**
  60348. * Post-process used to create volumetric lighting effect
  60349. */
  60350. volumetricLightPostProcess: Nullable<PostProcess>;
  60351. /**
  60352. * Post-process used to smooth the previous volumetric light post-process on the X axis
  60353. */
  60354. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  60355. /**
  60356. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  60357. */
  60358. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  60359. /**
  60360. * Post-process used to merge the volumetric light effect and the real scene color
  60361. */
  60362. volumetricLightMergePostProces: Nullable<PostProcess>;
  60363. /**
  60364. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  60365. */
  60366. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  60367. /**
  60368. * Base post-process used to calculate the average luminance of the final image for HDR
  60369. */
  60370. luminancePostProcess: Nullable<PostProcess>;
  60371. /**
  60372. * Post-processes used to create down sample post-processes in order to get
  60373. * the average luminance of the final image for HDR
  60374. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  60375. */
  60376. luminanceDownSamplePostProcesses: PostProcess[];
  60377. /**
  60378. * Post-process used to create a HDR effect (light adaptation)
  60379. */
  60380. hdrPostProcess: Nullable<PostProcess>;
  60381. /**
  60382. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  60383. */
  60384. textureAdderFinalPostProcess: Nullable<PostProcess>;
  60385. /**
  60386. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  60387. */
  60388. lensFlareFinalPostProcess: Nullable<PostProcess>;
  60389. /**
  60390. * Post-process used to merge the final HDR post-process and the real scene color
  60391. */
  60392. hdrFinalPostProcess: Nullable<PostProcess>;
  60393. /**
  60394. * Post-process used to create a lens flare effect
  60395. */
  60396. lensFlarePostProcess: Nullable<PostProcess>;
  60397. /**
  60398. * Post-process that merges the result of the lens flare post-process and the real scene color
  60399. */
  60400. lensFlareComposePostProcess: Nullable<PostProcess>;
  60401. /**
  60402. * Post-process used to create a motion blur effect
  60403. */
  60404. motionBlurPostProcess: Nullable<PostProcess>;
  60405. /**
  60406. * Post-process used to create a depth of field effect
  60407. */
  60408. depthOfFieldPostProcess: Nullable<PostProcess>;
  60409. /**
  60410. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60411. */
  60412. fxaaPostProcess: Nullable<FxaaPostProcess>;
  60413. /**
  60414. * Represents the brightness threshold in order to configure the illuminated surfaces
  60415. */
  60416. brightThreshold: number;
  60417. /**
  60418. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  60419. */
  60420. blurWidth: number;
  60421. /**
  60422. * Sets if the blur for highlighted surfaces must be only horizontal
  60423. */
  60424. horizontalBlur: boolean;
  60425. /**
  60426. * Gets the overall exposure used by the pipeline
  60427. */
  60428. /**
  60429. * Sets the overall exposure used by the pipeline
  60430. */
  60431. exposure: number;
  60432. /**
  60433. * Texture used typically to simulate "dirty" on camera lens
  60434. */
  60435. lensTexture: Nullable<Texture>;
  60436. /**
  60437. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  60438. */
  60439. volumetricLightCoefficient: number;
  60440. /**
  60441. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  60442. */
  60443. volumetricLightPower: number;
  60444. /**
  60445. * Used the set the blur intensity to smooth the volumetric lights
  60446. */
  60447. volumetricLightBlurScale: number;
  60448. /**
  60449. * Light (spot or directional) used to generate the volumetric lights rays
  60450. * The source light must have a shadow generate so the pipeline can get its
  60451. * depth map
  60452. */
  60453. sourceLight: Nullable<SpotLight | DirectionalLight>;
  60454. /**
  60455. * For eye adaptation, represents the minimum luminance the eye can see
  60456. */
  60457. hdrMinimumLuminance: number;
  60458. /**
  60459. * For eye adaptation, represents the decrease luminance speed
  60460. */
  60461. hdrDecreaseRate: number;
  60462. /**
  60463. * For eye adaptation, represents the increase luminance speed
  60464. */
  60465. hdrIncreaseRate: number;
  60466. /**
  60467. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60468. */
  60469. /**
  60470. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60471. */
  60472. hdrAutoExposure: boolean;
  60473. /**
  60474. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60475. */
  60476. lensColorTexture: Nullable<Texture>;
  60477. /**
  60478. * The overall strengh for the lens flare effect
  60479. */
  60480. lensFlareStrength: number;
  60481. /**
  60482. * Dispersion coefficient for lens flare ghosts
  60483. */
  60484. lensFlareGhostDispersal: number;
  60485. /**
  60486. * Main lens flare halo width
  60487. */
  60488. lensFlareHaloWidth: number;
  60489. /**
  60490. * Based on the lens distortion effect, defines how much the lens flare result
  60491. * is distorted
  60492. */
  60493. lensFlareDistortionStrength: number;
  60494. /**
  60495. * Configures the blur intensity used for for lens flare (halo)
  60496. */
  60497. lensFlareBlurWidth: number;
  60498. /**
  60499. * Lens star texture must be used to simulate rays on the flares and is available
  60500. * in the documentation
  60501. */
  60502. lensStarTexture: Nullable<Texture>;
  60503. /**
  60504. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60505. * flare effect by taking account of the dirt texture
  60506. */
  60507. lensFlareDirtTexture: Nullable<Texture>;
  60508. /**
  60509. * Represents the focal length for the depth of field effect
  60510. */
  60511. depthOfFieldDistance: number;
  60512. /**
  60513. * Represents the blur intensity for the blurred part of the depth of field effect
  60514. */
  60515. depthOfFieldBlurWidth: number;
  60516. /**
  60517. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60518. */
  60519. /**
  60520. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60521. */
  60522. motionStrength: number;
  60523. /**
  60524. * Gets wether or not the motion blur post-process is object based or screen based.
  60525. */
  60526. /**
  60527. * Sets wether or not the motion blur post-process should be object based or screen based
  60528. */
  60529. objectBasedMotionBlur: boolean;
  60530. /**
  60531. * List of animations for the pipeline (IAnimatable implementation)
  60532. */
  60533. animations: Animation[];
  60534. /**
  60535. * Private members
  60536. */
  60537. private _scene;
  60538. private _currentDepthOfFieldSource;
  60539. private _basePostProcess;
  60540. private _fixedExposure;
  60541. private _currentExposure;
  60542. private _hdrAutoExposure;
  60543. private _hdrCurrentLuminance;
  60544. private _motionStrength;
  60545. private _isObjectBasedMotionBlur;
  60546. private _floatTextureType;
  60547. private _camerasToBeAttached;
  60548. private _ratio;
  60549. private _bloomEnabled;
  60550. private _depthOfFieldEnabled;
  60551. private _vlsEnabled;
  60552. private _lensFlareEnabled;
  60553. private _hdrEnabled;
  60554. private _motionBlurEnabled;
  60555. private _fxaaEnabled;
  60556. private _motionBlurSamples;
  60557. private _volumetricLightStepsCount;
  60558. private _samples;
  60559. /**
  60560. * @ignore
  60561. * Specifies if the bloom pipeline is enabled
  60562. */
  60563. BloomEnabled: boolean;
  60564. /**
  60565. * @ignore
  60566. * Specifies if the depth of field pipeline is enabed
  60567. */
  60568. DepthOfFieldEnabled: boolean;
  60569. /**
  60570. * @ignore
  60571. * Specifies if the lens flare pipeline is enabed
  60572. */
  60573. LensFlareEnabled: boolean;
  60574. /**
  60575. * @ignore
  60576. * Specifies if the HDR pipeline is enabled
  60577. */
  60578. HDREnabled: boolean;
  60579. /**
  60580. * @ignore
  60581. * Specifies if the volumetric lights scattering effect is enabled
  60582. */
  60583. VLSEnabled: boolean;
  60584. /**
  60585. * @ignore
  60586. * Specifies if the motion blur effect is enabled
  60587. */
  60588. MotionBlurEnabled: boolean;
  60589. /**
  60590. * Specifies if anti-aliasing is enabled
  60591. */
  60592. fxaaEnabled: boolean;
  60593. /**
  60594. * Specifies the number of steps used to calculate the volumetric lights
  60595. * Typically in interval [50, 200]
  60596. */
  60597. volumetricLightStepsCount: number;
  60598. /**
  60599. * Specifies the number of samples used for the motion blur effect
  60600. * Typically in interval [16, 64]
  60601. */
  60602. motionBlurSamples: number;
  60603. /**
  60604. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60605. */
  60606. samples: number;
  60607. /**
  60608. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60609. * @constructor
  60610. * @param name The rendering pipeline name
  60611. * @param scene The scene linked to this pipeline
  60612. * @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)
  60613. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60614. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60615. */
  60616. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60617. private _buildPipeline;
  60618. private _createDownSampleX4PostProcess;
  60619. private _createBrightPassPostProcess;
  60620. private _createBlurPostProcesses;
  60621. private _createTextureAdderPostProcess;
  60622. private _createVolumetricLightPostProcess;
  60623. private _createLuminancePostProcesses;
  60624. private _createHdrPostProcess;
  60625. private _createLensFlarePostProcess;
  60626. private _createDepthOfFieldPostProcess;
  60627. private _createMotionBlurPostProcess;
  60628. private _getDepthTexture;
  60629. private _disposePostProcesses;
  60630. /**
  60631. * Dispose of the pipeline and stop all post processes
  60632. */
  60633. dispose(): void;
  60634. /**
  60635. * Serialize the rendering pipeline (Used when exporting)
  60636. * @returns the serialized object
  60637. */
  60638. serialize(): any;
  60639. /**
  60640. * Parse the serialized pipeline
  60641. * @param source Source pipeline.
  60642. * @param scene The scene to load the pipeline to.
  60643. * @param rootUrl The URL of the serialized pipeline.
  60644. * @returns An instantiated pipeline from the serialized object.
  60645. */
  60646. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60647. /**
  60648. * Luminance steps
  60649. */
  60650. static LuminanceSteps: number;
  60651. }
  60652. }
  60653. declare module BABYLON {
  60654. /** @hidden */
  60655. export var tonemapPixelShader: {
  60656. name: string;
  60657. shader: string;
  60658. };
  60659. }
  60660. declare module BABYLON {
  60661. /** Defines operator used for tonemapping */
  60662. export enum TonemappingOperator {
  60663. /** Hable */
  60664. Hable = 0,
  60665. /** Reinhard */
  60666. Reinhard = 1,
  60667. /** HejiDawson */
  60668. HejiDawson = 2,
  60669. /** Photographic */
  60670. Photographic = 3
  60671. }
  60672. /**
  60673. * Defines a post process to apply tone mapping
  60674. */
  60675. export class TonemapPostProcess extends PostProcess {
  60676. private _operator;
  60677. /** Defines the required exposure adjustement */
  60678. exposureAdjustment: number;
  60679. /**
  60680. * Creates a new TonemapPostProcess
  60681. * @param name defines the name of the postprocess
  60682. * @param _operator defines the operator to use
  60683. * @param exposureAdjustment defines the required exposure adjustement
  60684. * @param camera defines the camera to use (can be null)
  60685. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60686. * @param engine defines the hosting engine (can be ignore if camera is set)
  60687. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60688. */
  60689. constructor(name: string, _operator: TonemappingOperator,
  60690. /** Defines the required exposure adjustement */
  60691. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60692. }
  60693. }
  60694. declare module BABYLON {
  60695. /** @hidden */
  60696. export var depthVertexShader: {
  60697. name: string;
  60698. shader: string;
  60699. };
  60700. }
  60701. declare module BABYLON {
  60702. /** @hidden */
  60703. export var volumetricLightScatteringPixelShader: {
  60704. name: string;
  60705. shader: string;
  60706. };
  60707. }
  60708. declare module BABYLON {
  60709. /** @hidden */
  60710. export var volumetricLightScatteringPassVertexShader: {
  60711. name: string;
  60712. shader: string;
  60713. };
  60714. }
  60715. declare module BABYLON {
  60716. /** @hidden */
  60717. export var volumetricLightScatteringPassPixelShader: {
  60718. name: string;
  60719. shader: string;
  60720. };
  60721. }
  60722. declare module BABYLON {
  60723. /**
  60724. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60725. */
  60726. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60727. private _volumetricLightScatteringPass;
  60728. private _volumetricLightScatteringRTT;
  60729. private _viewPort;
  60730. private _screenCoordinates;
  60731. private _cachedDefines;
  60732. /**
  60733. * If not undefined, the mesh position is computed from the attached node position
  60734. */
  60735. attachedNode: {
  60736. position: Vector3;
  60737. };
  60738. /**
  60739. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60740. */
  60741. customMeshPosition: Vector3;
  60742. /**
  60743. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60744. */
  60745. useCustomMeshPosition: boolean;
  60746. /**
  60747. * If the post-process should inverse the light scattering direction
  60748. */
  60749. invert: boolean;
  60750. /**
  60751. * The internal mesh used by the post-process
  60752. */
  60753. mesh: Mesh;
  60754. /**
  60755. * @hidden
  60756. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60757. */
  60758. useDiffuseColor: boolean;
  60759. /**
  60760. * Array containing the excluded meshes not rendered in the internal pass
  60761. */
  60762. excludedMeshes: AbstractMesh[];
  60763. /**
  60764. * Controls the overall intensity of the post-process
  60765. */
  60766. exposure: number;
  60767. /**
  60768. * Dissipates each sample's contribution in range [0, 1]
  60769. */
  60770. decay: number;
  60771. /**
  60772. * Controls the overall intensity of each sample
  60773. */
  60774. weight: number;
  60775. /**
  60776. * Controls the density of each sample
  60777. */
  60778. density: number;
  60779. /**
  60780. * @constructor
  60781. * @param name The post-process name
  60782. * @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)
  60783. * @param camera The camera that the post-process will be attached to
  60784. * @param mesh The mesh used to create the light scattering
  60785. * @param samples The post-process quality, default 100
  60786. * @param samplingModeThe post-process filtering mode
  60787. * @param engine The babylon engine
  60788. * @param reusable If the post-process is reusable
  60789. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60790. */
  60791. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60792. /**
  60793. * Returns the string "VolumetricLightScatteringPostProcess"
  60794. * @returns "VolumetricLightScatteringPostProcess"
  60795. */
  60796. getClassName(): string;
  60797. private _isReady;
  60798. /**
  60799. * Sets the new light position for light scattering effect
  60800. * @param position The new custom light position
  60801. */
  60802. setCustomMeshPosition(position: Vector3): void;
  60803. /**
  60804. * Returns the light position for light scattering effect
  60805. * @return Vector3 The custom light position
  60806. */
  60807. getCustomMeshPosition(): Vector3;
  60808. /**
  60809. * Disposes the internal assets and detaches the post-process from the camera
  60810. */
  60811. dispose(camera: Camera): void;
  60812. /**
  60813. * Returns the render target texture used by the post-process
  60814. * @return the render target texture used by the post-process
  60815. */
  60816. getPass(): RenderTargetTexture;
  60817. private _meshExcluded;
  60818. private _createPass;
  60819. private _updateMeshScreenCoordinates;
  60820. /**
  60821. * Creates a default mesh for the Volumeric Light Scattering post-process
  60822. * @param name The mesh name
  60823. * @param scene The scene where to create the mesh
  60824. * @return the default mesh
  60825. */
  60826. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60827. }
  60828. }
  60829. declare module BABYLON {
  60830. interface Scene {
  60831. /** @hidden (Backing field) */
  60832. _boundingBoxRenderer: BoundingBoxRenderer;
  60833. /** @hidden (Backing field) */
  60834. _forceShowBoundingBoxes: boolean;
  60835. /**
  60836. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60837. */
  60838. forceShowBoundingBoxes: boolean;
  60839. /**
  60840. * Gets the bounding box renderer associated with the scene
  60841. * @returns a BoundingBoxRenderer
  60842. */
  60843. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60844. }
  60845. interface AbstractMesh {
  60846. /** @hidden (Backing field) */
  60847. _showBoundingBox: boolean;
  60848. /**
  60849. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60850. */
  60851. showBoundingBox: boolean;
  60852. }
  60853. /**
  60854. * Component responsible of rendering the bounding box of the meshes in a scene.
  60855. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60856. */
  60857. export class BoundingBoxRenderer implements ISceneComponent {
  60858. /**
  60859. * The component name helpfull to identify the component in the list of scene components.
  60860. */
  60861. readonly name: string;
  60862. /**
  60863. * The scene the component belongs to.
  60864. */
  60865. scene: Scene;
  60866. /**
  60867. * Color of the bounding box lines placed in front of an object
  60868. */
  60869. frontColor: Color3;
  60870. /**
  60871. * Color of the bounding box lines placed behind an object
  60872. */
  60873. backColor: Color3;
  60874. /**
  60875. * Defines if the renderer should show the back lines or not
  60876. */
  60877. showBackLines: boolean;
  60878. /**
  60879. * @hidden
  60880. */
  60881. renderList: SmartArray<BoundingBox>;
  60882. private _colorShader;
  60883. private _vertexBuffers;
  60884. private _indexBuffer;
  60885. private _fillIndexBuffer;
  60886. private _fillIndexData;
  60887. /**
  60888. * Instantiates a new bounding box renderer in a scene.
  60889. * @param scene the scene the renderer renders in
  60890. */
  60891. constructor(scene: Scene);
  60892. /**
  60893. * Registers the component in a given scene
  60894. */
  60895. register(): void;
  60896. private _evaluateSubMesh;
  60897. private _activeMesh;
  60898. private _prepareRessources;
  60899. private _createIndexBuffer;
  60900. /**
  60901. * Rebuilds the elements related to this component in case of
  60902. * context lost for instance.
  60903. */
  60904. rebuild(): void;
  60905. /**
  60906. * @hidden
  60907. */
  60908. reset(): void;
  60909. /**
  60910. * Render the bounding boxes of a specific rendering group
  60911. * @param renderingGroupId defines the rendering group to render
  60912. */
  60913. render(renderingGroupId: number): void;
  60914. /**
  60915. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60916. * @param mesh Define the mesh to render the occlusion bounding box for
  60917. */
  60918. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60919. /**
  60920. * Dispose and release the resources attached to this renderer.
  60921. */
  60922. dispose(): void;
  60923. }
  60924. }
  60925. declare module BABYLON {
  60926. /** @hidden */
  60927. export var depthPixelShader: {
  60928. name: string;
  60929. shader: string;
  60930. };
  60931. }
  60932. declare module BABYLON {
  60933. /**
  60934. * This represents a depth renderer in Babylon.
  60935. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60936. */
  60937. export class DepthRenderer {
  60938. private _scene;
  60939. private _depthMap;
  60940. private _effect;
  60941. private readonly _storeNonLinearDepth;
  60942. private readonly _clearColor;
  60943. /** Get if the depth renderer is using packed depth or not */
  60944. readonly isPacked: boolean;
  60945. private _cachedDefines;
  60946. private _camera;
  60947. /**
  60948. * Specifiess that the depth renderer will only be used within
  60949. * the camera it is created for.
  60950. * This can help forcing its rendering during the camera processing.
  60951. */
  60952. useOnlyInActiveCamera: boolean;
  60953. /** @hidden */
  60954. static _SceneComponentInitialization: (scene: Scene) => void;
  60955. /**
  60956. * Instantiates a depth renderer
  60957. * @param scene The scene the renderer belongs to
  60958. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60959. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60960. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60961. */
  60962. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60963. /**
  60964. * Creates the depth rendering effect and checks if the effect is ready.
  60965. * @param subMesh The submesh to be used to render the depth map of
  60966. * @param useInstances If multiple world instances should be used
  60967. * @returns if the depth renderer is ready to render the depth map
  60968. */
  60969. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60970. /**
  60971. * Gets the texture which the depth map will be written to.
  60972. * @returns The depth map texture
  60973. */
  60974. getDepthMap(): RenderTargetTexture;
  60975. /**
  60976. * Disposes of the depth renderer.
  60977. */
  60978. dispose(): void;
  60979. }
  60980. }
  60981. declare module BABYLON {
  60982. interface Scene {
  60983. /** @hidden (Backing field) */
  60984. _depthRenderer: {
  60985. [id: string]: DepthRenderer;
  60986. };
  60987. /**
  60988. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60989. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60990. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60991. * @returns the created depth renderer
  60992. */
  60993. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60994. /**
  60995. * Disables a depth renderer for a given camera
  60996. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60997. */
  60998. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60999. }
  61000. /**
  61001. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61002. * in several rendering techniques.
  61003. */
  61004. export class DepthRendererSceneComponent implements ISceneComponent {
  61005. /**
  61006. * The component name helpfull to identify the component in the list of scene components.
  61007. */
  61008. readonly name: string;
  61009. /**
  61010. * The scene the component belongs to.
  61011. */
  61012. scene: Scene;
  61013. /**
  61014. * Creates a new instance of the component for the given scene
  61015. * @param scene Defines the scene to register the component in
  61016. */
  61017. constructor(scene: Scene);
  61018. /**
  61019. * Registers the component in a given scene
  61020. */
  61021. register(): void;
  61022. /**
  61023. * Rebuilds the elements related to this component in case of
  61024. * context lost for instance.
  61025. */
  61026. rebuild(): void;
  61027. /**
  61028. * Disposes the component and the associated ressources
  61029. */
  61030. dispose(): void;
  61031. private _gatherRenderTargets;
  61032. private _gatherActiveCameraRenderTargets;
  61033. }
  61034. }
  61035. declare module BABYLON {
  61036. /** @hidden */
  61037. export var outlinePixelShader: {
  61038. name: string;
  61039. shader: string;
  61040. };
  61041. }
  61042. declare module BABYLON {
  61043. /** @hidden */
  61044. export var outlineVertexShader: {
  61045. name: string;
  61046. shader: string;
  61047. };
  61048. }
  61049. declare module BABYLON {
  61050. interface Scene {
  61051. /** @hidden */
  61052. _outlineRenderer: OutlineRenderer;
  61053. /**
  61054. * Gets the outline renderer associated with the scene
  61055. * @returns a OutlineRenderer
  61056. */
  61057. getOutlineRenderer(): OutlineRenderer;
  61058. }
  61059. interface AbstractMesh {
  61060. /** @hidden (Backing field) */
  61061. _renderOutline: boolean;
  61062. /**
  61063. * Gets or sets a boolean indicating if the outline must be rendered as well
  61064. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61065. */
  61066. renderOutline: boolean;
  61067. /** @hidden (Backing field) */
  61068. _renderOverlay: boolean;
  61069. /**
  61070. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61071. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61072. */
  61073. renderOverlay: boolean;
  61074. }
  61075. /**
  61076. * This class is responsible to draw bothe outline/overlay of meshes.
  61077. * It should not be used directly but through the available method on mesh.
  61078. */
  61079. export class OutlineRenderer implements ISceneComponent {
  61080. /**
  61081. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61082. */
  61083. private static _StencilReference;
  61084. /**
  61085. * The name of the component. Each component must have a unique name.
  61086. */
  61087. name: string;
  61088. /**
  61089. * The scene the component belongs to.
  61090. */
  61091. scene: Scene;
  61092. /**
  61093. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61094. */
  61095. zOffset: number;
  61096. private _engine;
  61097. private _effect;
  61098. private _cachedDefines;
  61099. private _savedDepthWrite;
  61100. /**
  61101. * Instantiates a new outline renderer. (There could be only one per scene).
  61102. * @param scene Defines the scene it belongs to
  61103. */
  61104. constructor(scene: Scene);
  61105. /**
  61106. * Register the component to one instance of a scene.
  61107. */
  61108. register(): void;
  61109. /**
  61110. * Rebuilds the elements related to this component in case of
  61111. * context lost for instance.
  61112. */
  61113. rebuild(): void;
  61114. /**
  61115. * Disposes the component and the associated ressources.
  61116. */
  61117. dispose(): void;
  61118. /**
  61119. * Renders the outline in the canvas.
  61120. * @param subMesh Defines the sumesh to render
  61121. * @param batch Defines the batch of meshes in case of instances
  61122. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61123. */
  61124. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61125. /**
  61126. * Returns whether or not the outline renderer is ready for a given submesh.
  61127. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61128. * @param subMesh Defines the submesh to check readyness for
  61129. * @param useInstances Defines wheter wee are trying to render instances or not
  61130. * @returns true if ready otherwise false
  61131. */
  61132. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61133. private _beforeRenderingMesh;
  61134. private _afterRenderingMesh;
  61135. }
  61136. }
  61137. declare module BABYLON {
  61138. /**
  61139. * Class used to manage multiple sprites of different sizes on the same spritesheet
  61140. * @see http://doc.babylonjs.com/babylon101/sprites
  61141. */
  61142. export class SpritePackedManager extends SpriteManager {
  61143. /** defines the packed manager's name */
  61144. name: string;
  61145. /**
  61146. * Creates a new sprite manager from a packed sprite sheet
  61147. * @param name defines the manager's name
  61148. * @param imgUrl defines the sprite sheet url
  61149. * @param capacity defines the maximum allowed number of sprites
  61150. * @param scene defines the hosting scene
  61151. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  61152. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  61153. * @param samplingMode defines the smapling mode to use with spritesheet
  61154. * @param fromPacked set to true; do not alter
  61155. */
  61156. constructor(
  61157. /** defines the packed manager's name */
  61158. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  61159. }
  61160. }
  61161. declare module BABYLON {
  61162. /**
  61163. * Defines the list of states available for a task inside a AssetsManager
  61164. */
  61165. export enum AssetTaskState {
  61166. /**
  61167. * Initialization
  61168. */
  61169. INIT = 0,
  61170. /**
  61171. * Running
  61172. */
  61173. RUNNING = 1,
  61174. /**
  61175. * Done
  61176. */
  61177. DONE = 2,
  61178. /**
  61179. * Error
  61180. */
  61181. ERROR = 3
  61182. }
  61183. /**
  61184. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61185. */
  61186. export abstract class AbstractAssetTask {
  61187. /**
  61188. * Task name
  61189. */ name: string;
  61190. /**
  61191. * Callback called when the task is successful
  61192. */
  61193. onSuccess: (task: any) => void;
  61194. /**
  61195. * Callback called when the task is not successful
  61196. */
  61197. onError: (task: any, message?: string, exception?: any) => void;
  61198. /**
  61199. * Creates a new AssetsManager
  61200. * @param name defines the name of the task
  61201. */
  61202. constructor(
  61203. /**
  61204. * Task name
  61205. */ name: string);
  61206. private _isCompleted;
  61207. private _taskState;
  61208. private _errorObject;
  61209. /**
  61210. * Get if the task is completed
  61211. */
  61212. readonly isCompleted: boolean;
  61213. /**
  61214. * Gets the current state of the task
  61215. */
  61216. readonly taskState: AssetTaskState;
  61217. /**
  61218. * Gets the current error object (if task is in error)
  61219. */
  61220. readonly errorObject: {
  61221. message?: string;
  61222. exception?: any;
  61223. };
  61224. /**
  61225. * Internal only
  61226. * @hidden
  61227. */
  61228. _setErrorObject(message?: string, exception?: any): void;
  61229. /**
  61230. * Execute the current task
  61231. * @param scene defines the scene where you want your assets to be loaded
  61232. * @param onSuccess is a callback called when the task is successfully executed
  61233. * @param onError is a callback called if an error occurs
  61234. */
  61235. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61236. /**
  61237. * Execute the current task
  61238. * @param scene defines the scene where you want your assets to be loaded
  61239. * @param onSuccess is a callback called when the task is successfully executed
  61240. * @param onError is a callback called if an error occurs
  61241. */
  61242. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61243. /**
  61244. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  61245. * This can be used with failed tasks that have the reason for failure fixed.
  61246. */
  61247. reset(): void;
  61248. private onErrorCallback;
  61249. private onDoneCallback;
  61250. }
  61251. /**
  61252. * Define the interface used by progress events raised during assets loading
  61253. */
  61254. export interface IAssetsProgressEvent {
  61255. /**
  61256. * Defines the number of remaining tasks to process
  61257. */
  61258. remainingCount: number;
  61259. /**
  61260. * Defines the total number of tasks
  61261. */
  61262. totalCount: number;
  61263. /**
  61264. * Defines the task that was just processed
  61265. */
  61266. task: AbstractAssetTask;
  61267. }
  61268. /**
  61269. * Class used to share progress information about assets loading
  61270. */
  61271. export class AssetsProgressEvent implements IAssetsProgressEvent {
  61272. /**
  61273. * Defines the number of remaining tasks to process
  61274. */
  61275. remainingCount: number;
  61276. /**
  61277. * Defines the total number of tasks
  61278. */
  61279. totalCount: number;
  61280. /**
  61281. * Defines the task that was just processed
  61282. */
  61283. task: AbstractAssetTask;
  61284. /**
  61285. * Creates a AssetsProgressEvent
  61286. * @param remainingCount defines the number of remaining tasks to process
  61287. * @param totalCount defines the total number of tasks
  61288. * @param task defines the task that was just processed
  61289. */
  61290. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  61291. }
  61292. /**
  61293. * Define a task used by AssetsManager to load meshes
  61294. */
  61295. export class MeshAssetTask extends AbstractAssetTask {
  61296. /**
  61297. * Defines the name of the task
  61298. */
  61299. name: string;
  61300. /**
  61301. * Defines the list of mesh's names you want to load
  61302. */
  61303. meshesNames: any;
  61304. /**
  61305. * Defines the root url to use as a base to load your meshes and associated resources
  61306. */
  61307. rootUrl: string;
  61308. /**
  61309. * Defines the filename of the scene to load from
  61310. */
  61311. sceneFilename: string;
  61312. /**
  61313. * Gets the list of loaded meshes
  61314. */
  61315. loadedMeshes: Array<AbstractMesh>;
  61316. /**
  61317. * Gets the list of loaded particle systems
  61318. */
  61319. loadedParticleSystems: Array<IParticleSystem>;
  61320. /**
  61321. * Gets the list of loaded skeletons
  61322. */
  61323. loadedSkeletons: Array<Skeleton>;
  61324. /**
  61325. * Gets the list of loaded animation groups
  61326. */
  61327. loadedAnimationGroups: Array<AnimationGroup>;
  61328. /**
  61329. * Callback called when the task is successful
  61330. */
  61331. onSuccess: (task: MeshAssetTask) => void;
  61332. /**
  61333. * Callback called when the task is successful
  61334. */
  61335. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  61336. /**
  61337. * Creates a new MeshAssetTask
  61338. * @param name defines the name of the task
  61339. * @param meshesNames defines the list of mesh's names you want to load
  61340. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  61341. * @param sceneFilename defines the filename of the scene to load from
  61342. */
  61343. constructor(
  61344. /**
  61345. * Defines the name of the task
  61346. */
  61347. name: string,
  61348. /**
  61349. * Defines the list of mesh's names you want to load
  61350. */
  61351. meshesNames: any,
  61352. /**
  61353. * Defines the root url to use as a base to load your meshes and associated resources
  61354. */
  61355. rootUrl: string,
  61356. /**
  61357. * Defines the filename of the scene to load from
  61358. */
  61359. sceneFilename: string);
  61360. /**
  61361. * Execute the current task
  61362. * @param scene defines the scene where you want your assets to be loaded
  61363. * @param onSuccess is a callback called when the task is successfully executed
  61364. * @param onError is a callback called if an error occurs
  61365. */
  61366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61367. }
  61368. /**
  61369. * Define a task used by AssetsManager to load text content
  61370. */
  61371. export class TextFileAssetTask extends AbstractAssetTask {
  61372. /**
  61373. * Defines the name of the task
  61374. */
  61375. name: string;
  61376. /**
  61377. * Defines the location of the file to load
  61378. */
  61379. url: string;
  61380. /**
  61381. * Gets the loaded text string
  61382. */
  61383. text: string;
  61384. /**
  61385. * Callback called when the task is successful
  61386. */
  61387. onSuccess: (task: TextFileAssetTask) => void;
  61388. /**
  61389. * Callback called when the task is successful
  61390. */
  61391. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61392. /**
  61393. * Creates a new TextFileAssetTask object
  61394. * @param name defines the name of the task
  61395. * @param url defines the location of the file to load
  61396. */
  61397. constructor(
  61398. /**
  61399. * Defines the name of the task
  61400. */
  61401. name: string,
  61402. /**
  61403. * Defines the location of the file to load
  61404. */
  61405. url: string);
  61406. /**
  61407. * Execute the current task
  61408. * @param scene defines the scene where you want your assets to be loaded
  61409. * @param onSuccess is a callback called when the task is successfully executed
  61410. * @param onError is a callback called if an error occurs
  61411. */
  61412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61413. }
  61414. /**
  61415. * Define a task used by AssetsManager to load binary data
  61416. */
  61417. export class BinaryFileAssetTask extends AbstractAssetTask {
  61418. /**
  61419. * Defines the name of the task
  61420. */
  61421. name: string;
  61422. /**
  61423. * Defines the location of the file to load
  61424. */
  61425. url: string;
  61426. /**
  61427. * Gets the lodaded data (as an array buffer)
  61428. */
  61429. data: ArrayBuffer;
  61430. /**
  61431. * Callback called when the task is successful
  61432. */
  61433. onSuccess: (task: BinaryFileAssetTask) => void;
  61434. /**
  61435. * Callback called when the task is successful
  61436. */
  61437. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61438. /**
  61439. * Creates a new BinaryFileAssetTask object
  61440. * @param name defines the name of the new task
  61441. * @param url defines the location of the file to load
  61442. */
  61443. constructor(
  61444. /**
  61445. * Defines the name of the task
  61446. */
  61447. name: string,
  61448. /**
  61449. * Defines the location of the file to load
  61450. */
  61451. url: string);
  61452. /**
  61453. * Execute the current task
  61454. * @param scene defines the scene where you want your assets to be loaded
  61455. * @param onSuccess is a callback called when the task is successfully executed
  61456. * @param onError is a callback called if an error occurs
  61457. */
  61458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61459. }
  61460. /**
  61461. * Define a task used by AssetsManager to load images
  61462. */
  61463. export class ImageAssetTask extends AbstractAssetTask {
  61464. /**
  61465. * Defines the name of the task
  61466. */
  61467. name: string;
  61468. /**
  61469. * Defines the location of the image to load
  61470. */
  61471. url: string;
  61472. /**
  61473. * Gets the loaded images
  61474. */
  61475. image: HTMLImageElement;
  61476. /**
  61477. * Callback called when the task is successful
  61478. */
  61479. onSuccess: (task: ImageAssetTask) => void;
  61480. /**
  61481. * Callback called when the task is successful
  61482. */
  61483. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61484. /**
  61485. * Creates a new ImageAssetTask
  61486. * @param name defines the name of the task
  61487. * @param url defines the location of the image to load
  61488. */
  61489. constructor(
  61490. /**
  61491. * Defines the name of the task
  61492. */
  61493. name: string,
  61494. /**
  61495. * Defines the location of the image to load
  61496. */
  61497. url: string);
  61498. /**
  61499. * Execute the current task
  61500. * @param scene defines the scene where you want your assets to be loaded
  61501. * @param onSuccess is a callback called when the task is successfully executed
  61502. * @param onError is a callback called if an error occurs
  61503. */
  61504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61505. }
  61506. /**
  61507. * Defines the interface used by texture loading tasks
  61508. */
  61509. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61510. /**
  61511. * Gets the loaded texture
  61512. */
  61513. texture: TEX;
  61514. }
  61515. /**
  61516. * Define a task used by AssetsManager to load 2D textures
  61517. */
  61518. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61519. /**
  61520. * Defines the name of the task
  61521. */
  61522. name: string;
  61523. /**
  61524. * Defines the location of the file to load
  61525. */
  61526. url: string;
  61527. /**
  61528. * Defines if mipmap should not be generated (default is false)
  61529. */
  61530. noMipmap?: boolean | undefined;
  61531. /**
  61532. * Defines if texture must be inverted on Y axis (default is false)
  61533. */
  61534. invertY?: boolean | undefined;
  61535. /**
  61536. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61537. */
  61538. samplingMode: number;
  61539. /**
  61540. * Gets the loaded texture
  61541. */
  61542. texture: Texture;
  61543. /**
  61544. * Callback called when the task is successful
  61545. */
  61546. onSuccess: (task: TextureAssetTask) => void;
  61547. /**
  61548. * Callback called when the task is successful
  61549. */
  61550. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61551. /**
  61552. * Creates a new TextureAssetTask object
  61553. * @param name defines the name of the task
  61554. * @param url defines the location of the file to load
  61555. * @param noMipmap defines if mipmap should not be generated (default is false)
  61556. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61557. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61558. */
  61559. constructor(
  61560. /**
  61561. * Defines the name of the task
  61562. */
  61563. name: string,
  61564. /**
  61565. * Defines the location of the file to load
  61566. */
  61567. url: string,
  61568. /**
  61569. * Defines if mipmap should not be generated (default is false)
  61570. */
  61571. noMipmap?: boolean | undefined,
  61572. /**
  61573. * Defines if texture must be inverted on Y axis (default is false)
  61574. */
  61575. invertY?: boolean | undefined,
  61576. /**
  61577. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61578. */
  61579. samplingMode?: number);
  61580. /**
  61581. * Execute the current task
  61582. * @param scene defines the scene where you want your assets to be loaded
  61583. * @param onSuccess is a callback called when the task is successfully executed
  61584. * @param onError is a callback called if an error occurs
  61585. */
  61586. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61587. }
  61588. /**
  61589. * Define a task used by AssetsManager to load cube textures
  61590. */
  61591. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61592. /**
  61593. * Defines the name of the task
  61594. */
  61595. name: string;
  61596. /**
  61597. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61598. */
  61599. url: string;
  61600. /**
  61601. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61602. */
  61603. extensions?: string[] | undefined;
  61604. /**
  61605. * Defines if mipmaps should not be generated (default is false)
  61606. */
  61607. noMipmap?: boolean | undefined;
  61608. /**
  61609. * Defines the explicit list of files (undefined by default)
  61610. */
  61611. files?: string[] | undefined;
  61612. /**
  61613. * Gets the loaded texture
  61614. */
  61615. texture: CubeTexture;
  61616. /**
  61617. * Callback called when the task is successful
  61618. */
  61619. onSuccess: (task: CubeTextureAssetTask) => void;
  61620. /**
  61621. * Callback called when the task is successful
  61622. */
  61623. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61624. /**
  61625. * Creates a new CubeTextureAssetTask
  61626. * @param name defines the name of the task
  61627. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61628. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61629. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61630. * @param files defines the explicit list of files (undefined by default)
  61631. */
  61632. constructor(
  61633. /**
  61634. * Defines the name of the task
  61635. */
  61636. name: string,
  61637. /**
  61638. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61639. */
  61640. url: string,
  61641. /**
  61642. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61643. */
  61644. extensions?: string[] | undefined,
  61645. /**
  61646. * Defines if mipmaps should not be generated (default is false)
  61647. */
  61648. noMipmap?: boolean | undefined,
  61649. /**
  61650. * Defines the explicit list of files (undefined by default)
  61651. */
  61652. files?: string[] | undefined);
  61653. /**
  61654. * Execute the current task
  61655. * @param scene defines the scene where you want your assets to be loaded
  61656. * @param onSuccess is a callback called when the task is successfully executed
  61657. * @param onError is a callback called if an error occurs
  61658. */
  61659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61660. }
  61661. /**
  61662. * Define a task used by AssetsManager to load HDR cube textures
  61663. */
  61664. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61665. /**
  61666. * Defines the name of the task
  61667. */
  61668. name: string;
  61669. /**
  61670. * Defines the location of the file to load
  61671. */
  61672. url: string;
  61673. /**
  61674. * Defines the desired size (the more it increases the longer the generation will be)
  61675. */
  61676. size: number;
  61677. /**
  61678. * Defines if mipmaps should not be generated (default is false)
  61679. */
  61680. noMipmap: boolean;
  61681. /**
  61682. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61683. */
  61684. generateHarmonics: boolean;
  61685. /**
  61686. * 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)
  61687. */
  61688. gammaSpace: boolean;
  61689. /**
  61690. * Internal Use Only
  61691. */
  61692. reserved: boolean;
  61693. /**
  61694. * Gets the loaded texture
  61695. */
  61696. texture: HDRCubeTexture;
  61697. /**
  61698. * Callback called when the task is successful
  61699. */
  61700. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61701. /**
  61702. * Callback called when the task is successful
  61703. */
  61704. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61705. /**
  61706. * Creates a new HDRCubeTextureAssetTask object
  61707. * @param name defines the name of the task
  61708. * @param url defines the location of the file to load
  61709. * @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.
  61710. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61711. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61712. * @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)
  61713. * @param reserved Internal use only
  61714. */
  61715. constructor(
  61716. /**
  61717. * Defines the name of the task
  61718. */
  61719. name: string,
  61720. /**
  61721. * Defines the location of the file to load
  61722. */
  61723. url: string,
  61724. /**
  61725. * Defines the desired size (the more it increases the longer the generation will be)
  61726. */
  61727. size: number,
  61728. /**
  61729. * Defines if mipmaps should not be generated (default is false)
  61730. */
  61731. noMipmap?: boolean,
  61732. /**
  61733. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61734. */
  61735. generateHarmonics?: boolean,
  61736. /**
  61737. * 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)
  61738. */
  61739. gammaSpace?: boolean,
  61740. /**
  61741. * Internal Use Only
  61742. */
  61743. reserved?: boolean);
  61744. /**
  61745. * Execute the current task
  61746. * @param scene defines the scene where you want your assets to be loaded
  61747. * @param onSuccess is a callback called when the task is successfully executed
  61748. * @param onError is a callback called if an error occurs
  61749. */
  61750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61751. }
  61752. /**
  61753. * Define a task used by AssetsManager to load Equirectangular cube textures
  61754. */
  61755. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61756. /**
  61757. * Defines the name of the task
  61758. */
  61759. name: string;
  61760. /**
  61761. * Defines the location of the file to load
  61762. */
  61763. url: string;
  61764. /**
  61765. * Defines the desired size (the more it increases the longer the generation will be)
  61766. */
  61767. size: number;
  61768. /**
  61769. * Defines if mipmaps should not be generated (default is false)
  61770. */
  61771. noMipmap: boolean;
  61772. /**
  61773. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61774. * but the standard material would require them in Gamma space) (default is true)
  61775. */
  61776. gammaSpace: boolean;
  61777. /**
  61778. * Gets the loaded texture
  61779. */
  61780. texture: EquiRectangularCubeTexture;
  61781. /**
  61782. * Callback called when the task is successful
  61783. */
  61784. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61785. /**
  61786. * Callback called when the task is successful
  61787. */
  61788. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61789. /**
  61790. * Creates a new EquiRectangularCubeTextureAssetTask object
  61791. * @param name defines the name of the task
  61792. * @param url defines the location of the file to load
  61793. * @param size defines the desired size (the more it increases the longer the generation will be)
  61794. * If the size is omitted this implies you are using a preprocessed cubemap.
  61795. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61796. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61797. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61798. * (default is true)
  61799. */
  61800. constructor(
  61801. /**
  61802. * Defines the name of the task
  61803. */
  61804. name: string,
  61805. /**
  61806. * Defines the location of the file to load
  61807. */
  61808. url: string,
  61809. /**
  61810. * Defines the desired size (the more it increases the longer the generation will be)
  61811. */
  61812. size: number,
  61813. /**
  61814. * Defines if mipmaps should not be generated (default is false)
  61815. */
  61816. noMipmap?: boolean,
  61817. /**
  61818. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61819. * but the standard material would require them in Gamma space) (default is true)
  61820. */
  61821. gammaSpace?: boolean);
  61822. /**
  61823. * Execute the current task
  61824. * @param scene defines the scene where you want your assets to be loaded
  61825. * @param onSuccess is a callback called when the task is successfully executed
  61826. * @param onError is a callback called if an error occurs
  61827. */
  61828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61829. }
  61830. /**
  61831. * This class can be used to easily import assets into a scene
  61832. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61833. */
  61834. export class AssetsManager {
  61835. private _scene;
  61836. private _isLoading;
  61837. protected _tasks: AbstractAssetTask[];
  61838. protected _waitingTasksCount: number;
  61839. protected _totalTasksCount: number;
  61840. /**
  61841. * Callback called when all tasks are processed
  61842. */
  61843. onFinish: (tasks: AbstractAssetTask[]) => void;
  61844. /**
  61845. * Callback called when a task is successful
  61846. */
  61847. onTaskSuccess: (task: AbstractAssetTask) => void;
  61848. /**
  61849. * Callback called when a task had an error
  61850. */
  61851. onTaskError: (task: AbstractAssetTask) => void;
  61852. /**
  61853. * Callback called when a task is done (whatever the result is)
  61854. */
  61855. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61856. /**
  61857. * Observable called when all tasks are processed
  61858. */
  61859. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61860. /**
  61861. * Observable called when a task had an error
  61862. */
  61863. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61864. /**
  61865. * Observable called when all tasks were executed
  61866. */
  61867. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61868. /**
  61869. * Observable called when a task is done (whatever the result is)
  61870. */
  61871. onProgressObservable: Observable<IAssetsProgressEvent>;
  61872. /**
  61873. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61875. */
  61876. useDefaultLoadingScreen: boolean;
  61877. /**
  61878. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61879. * when all assets have been downloaded.
  61880. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61881. */
  61882. autoHideLoadingUI: boolean;
  61883. /**
  61884. * Creates a new AssetsManager
  61885. * @param scene defines the scene to work on
  61886. */
  61887. constructor(scene: Scene);
  61888. /**
  61889. * Add a MeshAssetTask to the list of active tasks
  61890. * @param taskName defines the name of the new task
  61891. * @param meshesNames defines the name of meshes to load
  61892. * @param rootUrl defines the root url to use to locate files
  61893. * @param sceneFilename defines the filename of the scene file
  61894. * @returns a new MeshAssetTask object
  61895. */
  61896. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61897. /**
  61898. * Add a TextFileAssetTask to the list of active tasks
  61899. * @param taskName defines the name of the new task
  61900. * @param url defines the url of the file to load
  61901. * @returns a new TextFileAssetTask object
  61902. */
  61903. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61904. /**
  61905. * Add a BinaryFileAssetTask to the list of active tasks
  61906. * @param taskName defines the name of the new task
  61907. * @param url defines the url of the file to load
  61908. * @returns a new BinaryFileAssetTask object
  61909. */
  61910. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61911. /**
  61912. * Add a ImageAssetTask to the list of active tasks
  61913. * @param taskName defines the name of the new task
  61914. * @param url defines the url of the file to load
  61915. * @returns a new ImageAssetTask object
  61916. */
  61917. addImageTask(taskName: string, url: string): ImageAssetTask;
  61918. /**
  61919. * Add a TextureAssetTask to the list of active tasks
  61920. * @param taskName defines the name of the new task
  61921. * @param url defines the url of the file to load
  61922. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61923. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61924. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61925. * @returns a new TextureAssetTask object
  61926. */
  61927. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61928. /**
  61929. * Add a CubeTextureAssetTask to the list of active tasks
  61930. * @param taskName defines the name of the new task
  61931. * @param url defines the url of the file to load
  61932. * @param extensions defines the extension to use to load the cube map (can be null)
  61933. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61934. * @param files defines the list of files to load (can be null)
  61935. * @returns a new CubeTextureAssetTask object
  61936. */
  61937. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61938. /**
  61939. *
  61940. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61941. * @param taskName defines the name of the new task
  61942. * @param url defines the url of the file to load
  61943. * @param size defines the size you want for the cubemap (can be null)
  61944. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61945. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61946. * @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)
  61947. * @param reserved Internal use only
  61948. * @returns a new HDRCubeTextureAssetTask object
  61949. */
  61950. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61951. /**
  61952. *
  61953. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61954. * @param taskName defines the name of the new task
  61955. * @param url defines the url of the file to load
  61956. * @param size defines the size you want for the cubemap (can be null)
  61957. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61958. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61959. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61960. * @returns a new EquiRectangularCubeTextureAssetTask object
  61961. */
  61962. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61963. /**
  61964. * Remove a task from the assets manager.
  61965. * @param task the task to remove
  61966. */
  61967. removeTask(task: AbstractAssetTask): void;
  61968. private _decreaseWaitingTasksCount;
  61969. private _runTask;
  61970. /**
  61971. * Reset the AssetsManager and remove all tasks
  61972. * @return the current instance of the AssetsManager
  61973. */
  61974. reset(): AssetsManager;
  61975. /**
  61976. * Start the loading process
  61977. * @return the current instance of the AssetsManager
  61978. */
  61979. load(): AssetsManager;
  61980. /**
  61981. * Start the loading process as an async operation
  61982. * @return a promise returning the list of failed tasks
  61983. */
  61984. loadAsync(): Promise<void>;
  61985. }
  61986. }
  61987. declare module BABYLON {
  61988. /**
  61989. * Wrapper class for promise with external resolve and reject.
  61990. */
  61991. export class Deferred<T> {
  61992. /**
  61993. * The promise associated with this deferred object.
  61994. */
  61995. readonly promise: Promise<T>;
  61996. private _resolve;
  61997. private _reject;
  61998. /**
  61999. * The resolve method of the promise associated with this deferred object.
  62000. */
  62001. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62002. /**
  62003. * The reject method of the promise associated with this deferred object.
  62004. */
  62005. readonly reject: (reason?: any) => void;
  62006. /**
  62007. * Constructor for this deferred object.
  62008. */
  62009. constructor();
  62010. }
  62011. }
  62012. declare module BABYLON {
  62013. /**
  62014. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62015. */
  62016. export class MeshExploder {
  62017. private _centerMesh;
  62018. private _meshes;
  62019. private _meshesOrigins;
  62020. private _toCenterVectors;
  62021. private _scaledDirection;
  62022. private _newPosition;
  62023. private _centerPosition;
  62024. /**
  62025. * Explodes meshes from a center mesh.
  62026. * @param meshes The meshes to explode.
  62027. * @param centerMesh The mesh to be center of explosion.
  62028. */
  62029. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62030. private _setCenterMesh;
  62031. /**
  62032. * Get class name
  62033. * @returns "MeshExploder"
  62034. */
  62035. getClassName(): string;
  62036. /**
  62037. * "Exploded meshes"
  62038. * @returns Array of meshes with the centerMesh at index 0.
  62039. */
  62040. getMeshes(): Array<Mesh>;
  62041. /**
  62042. * Explodes meshes giving a specific direction
  62043. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62044. */
  62045. explode(direction?: number): void;
  62046. }
  62047. }
  62048. declare module BABYLON {
  62049. /**
  62050. * Class used to help managing file picking and drag'n'drop
  62051. */
  62052. export class FilesInput {
  62053. /**
  62054. * List of files ready to be loaded
  62055. */
  62056. static readonly FilesToLoad: {
  62057. [key: string]: File;
  62058. };
  62059. /**
  62060. * Callback called when a file is processed
  62061. */
  62062. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62063. private _engine;
  62064. private _currentScene;
  62065. private _sceneLoadedCallback;
  62066. private _progressCallback;
  62067. private _additionalRenderLoopLogicCallback;
  62068. private _textureLoadingCallback;
  62069. private _startingProcessingFilesCallback;
  62070. private _onReloadCallback;
  62071. private _errorCallback;
  62072. private _elementToMonitor;
  62073. private _sceneFileToLoad;
  62074. private _filesToLoad;
  62075. /**
  62076. * Creates a new FilesInput
  62077. * @param engine defines the rendering engine
  62078. * @param scene defines the hosting scene
  62079. * @param sceneLoadedCallback callback called when scene is loaded
  62080. * @param progressCallback callback called to track progress
  62081. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62082. * @param textureLoadingCallback callback called when a texture is loading
  62083. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62084. * @param onReloadCallback callback called when a reload is requested
  62085. * @param errorCallback callback call if an error occurs
  62086. */
  62087. 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);
  62088. private _dragEnterHandler;
  62089. private _dragOverHandler;
  62090. private _dropHandler;
  62091. /**
  62092. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62093. * @param elementToMonitor defines the DOM element to track
  62094. */
  62095. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62096. /**
  62097. * Release all associated resources
  62098. */
  62099. dispose(): void;
  62100. private renderFunction;
  62101. private drag;
  62102. private drop;
  62103. private _traverseFolder;
  62104. private _processFiles;
  62105. /**
  62106. * Load files from a drop event
  62107. * @param event defines the drop event to use as source
  62108. */
  62109. loadFiles(event: any): void;
  62110. private _processReload;
  62111. /**
  62112. * Reload the current scene from the loaded files
  62113. */
  62114. reload(): void;
  62115. }
  62116. }
  62117. declare module BABYLON {
  62118. /**
  62119. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62121. */
  62122. export class SceneOptimization {
  62123. /**
  62124. * Defines the priority of this optimization (0 by default which means first in the list)
  62125. */
  62126. priority: number;
  62127. /**
  62128. * Gets a string describing the action executed by the current optimization
  62129. * @returns description string
  62130. */
  62131. getDescription(): string;
  62132. /**
  62133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62134. * @param scene defines the current scene where to apply this optimization
  62135. * @param optimizer defines the current optimizer
  62136. * @returns true if everything that can be done was applied
  62137. */
  62138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62139. /**
  62140. * Creates the SceneOptimization object
  62141. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62142. * @param desc defines the description associated with the optimization
  62143. */
  62144. constructor(
  62145. /**
  62146. * Defines the priority of this optimization (0 by default which means first in the list)
  62147. */
  62148. priority?: number);
  62149. }
  62150. /**
  62151. * Defines an optimization used to reduce the size of render target textures
  62152. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62153. */
  62154. export class TextureOptimization extends SceneOptimization {
  62155. /**
  62156. * Defines the priority of this optimization (0 by default which means first in the list)
  62157. */
  62158. priority: number;
  62159. /**
  62160. * 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
  62161. */
  62162. maximumSize: number;
  62163. /**
  62164. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62165. */
  62166. step: number;
  62167. /**
  62168. * Gets a string describing the action executed by the current optimization
  62169. * @returns description string
  62170. */
  62171. getDescription(): string;
  62172. /**
  62173. * Creates the TextureOptimization object
  62174. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62175. * @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
  62176. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62177. */
  62178. constructor(
  62179. /**
  62180. * Defines the priority of this optimization (0 by default which means first in the list)
  62181. */
  62182. priority?: number,
  62183. /**
  62184. * 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
  62185. */
  62186. maximumSize?: number,
  62187. /**
  62188. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62189. */
  62190. step?: number);
  62191. /**
  62192. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62193. * @param scene defines the current scene where to apply this optimization
  62194. * @param optimizer defines the current optimizer
  62195. * @returns true if everything that can be done was applied
  62196. */
  62197. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62198. }
  62199. /**
  62200. * Defines an optimization used to increase or decrease the rendering resolution
  62201. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62202. */
  62203. export class HardwareScalingOptimization extends SceneOptimization {
  62204. /**
  62205. * Defines the priority of this optimization (0 by default which means first in the list)
  62206. */
  62207. priority: number;
  62208. /**
  62209. * Defines the maximum scale to use (2 by default)
  62210. */
  62211. maximumScale: number;
  62212. /**
  62213. * Defines the step to use between two passes (0.5 by default)
  62214. */
  62215. step: number;
  62216. private _currentScale;
  62217. private _directionOffset;
  62218. /**
  62219. * Gets a string describing the action executed by the current optimization
  62220. * @return description string
  62221. */
  62222. getDescription(): string;
  62223. /**
  62224. * Creates the HardwareScalingOptimization object
  62225. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62226. * @param maximumScale defines the maximum scale to use (2 by default)
  62227. * @param step defines the step to use between two passes (0.5 by default)
  62228. */
  62229. constructor(
  62230. /**
  62231. * Defines the priority of this optimization (0 by default which means first in the list)
  62232. */
  62233. priority?: number,
  62234. /**
  62235. * Defines the maximum scale to use (2 by default)
  62236. */
  62237. maximumScale?: number,
  62238. /**
  62239. * Defines the step to use between two passes (0.5 by default)
  62240. */
  62241. step?: number);
  62242. /**
  62243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62244. * @param scene defines the current scene where to apply this optimization
  62245. * @param optimizer defines the current optimizer
  62246. * @returns true if everything that can be done was applied
  62247. */
  62248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62249. }
  62250. /**
  62251. * Defines an optimization used to remove shadows
  62252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62253. */
  62254. export class ShadowsOptimization extends SceneOptimization {
  62255. /**
  62256. * Gets a string describing the action executed by the current optimization
  62257. * @return description string
  62258. */
  62259. getDescription(): string;
  62260. /**
  62261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62262. * @param scene defines the current scene where to apply this optimization
  62263. * @param optimizer defines the current optimizer
  62264. * @returns true if everything that can be done was applied
  62265. */
  62266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62267. }
  62268. /**
  62269. * Defines an optimization used to turn post-processes off
  62270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62271. */
  62272. export class PostProcessesOptimization extends SceneOptimization {
  62273. /**
  62274. * Gets a string describing the action executed by the current optimization
  62275. * @return description string
  62276. */
  62277. getDescription(): string;
  62278. /**
  62279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62280. * @param scene defines the current scene where to apply this optimization
  62281. * @param optimizer defines the current optimizer
  62282. * @returns true if everything that can be done was applied
  62283. */
  62284. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62285. }
  62286. /**
  62287. * Defines an optimization used to turn lens flares off
  62288. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62289. */
  62290. export class LensFlaresOptimization extends SceneOptimization {
  62291. /**
  62292. * Gets a string describing the action executed by the current optimization
  62293. * @return description string
  62294. */
  62295. getDescription(): string;
  62296. /**
  62297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62298. * @param scene defines the current scene where to apply this optimization
  62299. * @param optimizer defines the current optimizer
  62300. * @returns true if everything that can be done was applied
  62301. */
  62302. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62303. }
  62304. /**
  62305. * Defines an optimization based on user defined callback.
  62306. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62307. */
  62308. export class CustomOptimization extends SceneOptimization {
  62309. /**
  62310. * Callback called to apply the custom optimization.
  62311. */
  62312. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  62313. /**
  62314. * Callback called to get custom description
  62315. */
  62316. onGetDescription: () => string;
  62317. /**
  62318. * Gets a string describing the action executed by the current optimization
  62319. * @returns description string
  62320. */
  62321. getDescription(): string;
  62322. /**
  62323. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62324. * @param scene defines the current scene where to apply this optimization
  62325. * @param optimizer defines the current optimizer
  62326. * @returns true if everything that can be done was applied
  62327. */
  62328. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62329. }
  62330. /**
  62331. * Defines an optimization used to turn particles off
  62332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62333. */
  62334. export class ParticlesOptimization extends SceneOptimization {
  62335. /**
  62336. * Gets a string describing the action executed by the current optimization
  62337. * @return description string
  62338. */
  62339. getDescription(): string;
  62340. /**
  62341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62342. * @param scene defines the current scene where to apply this optimization
  62343. * @param optimizer defines the current optimizer
  62344. * @returns true if everything that can be done was applied
  62345. */
  62346. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62347. }
  62348. /**
  62349. * Defines an optimization used to turn render targets off
  62350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62351. */
  62352. export class RenderTargetsOptimization extends SceneOptimization {
  62353. /**
  62354. * Gets a string describing the action executed by the current optimization
  62355. * @return description string
  62356. */
  62357. getDescription(): string;
  62358. /**
  62359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62360. * @param scene defines the current scene where to apply this optimization
  62361. * @param optimizer defines the current optimizer
  62362. * @returns true if everything that can be done was applied
  62363. */
  62364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62365. }
  62366. /**
  62367. * Defines an optimization used to merge meshes with compatible materials
  62368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62369. */
  62370. export class MergeMeshesOptimization extends SceneOptimization {
  62371. private static _UpdateSelectionTree;
  62372. /**
  62373. * Gets or sets a boolean which defines if optimization octree has to be updated
  62374. */
  62375. /**
  62376. * Gets or sets a boolean which defines if optimization octree has to be updated
  62377. */
  62378. static UpdateSelectionTree: boolean;
  62379. /**
  62380. * Gets a string describing the action executed by the current optimization
  62381. * @return description string
  62382. */
  62383. getDescription(): string;
  62384. private _canBeMerged;
  62385. /**
  62386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62387. * @param scene defines the current scene where to apply this optimization
  62388. * @param optimizer defines the current optimizer
  62389. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62390. * @returns true if everything that can be done was applied
  62391. */
  62392. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62393. }
  62394. /**
  62395. * Defines a list of options used by SceneOptimizer
  62396. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62397. */
  62398. export class SceneOptimizerOptions {
  62399. /**
  62400. * Defines the target frame rate to reach (60 by default)
  62401. */
  62402. targetFrameRate: number;
  62403. /**
  62404. * Defines the interval between two checkes (2000ms by default)
  62405. */
  62406. trackerDuration: number;
  62407. /**
  62408. * Gets the list of optimizations to apply
  62409. */
  62410. optimizations: SceneOptimization[];
  62411. /**
  62412. * Creates a new list of options used by SceneOptimizer
  62413. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62414. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62415. */
  62416. constructor(
  62417. /**
  62418. * Defines the target frame rate to reach (60 by default)
  62419. */
  62420. targetFrameRate?: number,
  62421. /**
  62422. * Defines the interval between two checkes (2000ms by default)
  62423. */
  62424. trackerDuration?: number);
  62425. /**
  62426. * Add a new optimization
  62427. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62428. * @returns the current SceneOptimizerOptions
  62429. */
  62430. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62431. /**
  62432. * Add a new custom optimization
  62433. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62434. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62435. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62436. * @returns the current SceneOptimizerOptions
  62437. */
  62438. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62439. /**
  62440. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62441. * @param targetFrameRate defines the target frame rate (60 by default)
  62442. * @returns a SceneOptimizerOptions object
  62443. */
  62444. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62445. /**
  62446. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62447. * @param targetFrameRate defines the target frame rate (60 by default)
  62448. * @returns a SceneOptimizerOptions object
  62449. */
  62450. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62451. /**
  62452. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62453. * @param targetFrameRate defines the target frame rate (60 by default)
  62454. * @returns a SceneOptimizerOptions object
  62455. */
  62456. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62457. }
  62458. /**
  62459. * Class used to run optimizations in order to reach a target frame rate
  62460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62461. */
  62462. export class SceneOptimizer implements IDisposable {
  62463. private _isRunning;
  62464. private _options;
  62465. private _scene;
  62466. private _currentPriorityLevel;
  62467. private _targetFrameRate;
  62468. private _trackerDuration;
  62469. private _currentFrameRate;
  62470. private _sceneDisposeObserver;
  62471. private _improvementMode;
  62472. /**
  62473. * Defines an observable called when the optimizer reaches the target frame rate
  62474. */
  62475. onSuccessObservable: Observable<SceneOptimizer>;
  62476. /**
  62477. * Defines an observable called when the optimizer enables an optimization
  62478. */
  62479. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62480. /**
  62481. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62482. */
  62483. onFailureObservable: Observable<SceneOptimizer>;
  62484. /**
  62485. * Gets a boolean indicating if the optimizer is in improvement mode
  62486. */
  62487. readonly isInImprovementMode: boolean;
  62488. /**
  62489. * Gets the current priority level (0 at start)
  62490. */
  62491. readonly currentPriorityLevel: number;
  62492. /**
  62493. * Gets the current frame rate checked by the SceneOptimizer
  62494. */
  62495. readonly currentFrameRate: number;
  62496. /**
  62497. * Gets or sets the current target frame rate (60 by default)
  62498. */
  62499. /**
  62500. * Gets or sets the current target frame rate (60 by default)
  62501. */
  62502. targetFrameRate: number;
  62503. /**
  62504. * Gets or sets the current interval between two checks (every 2000ms by default)
  62505. */
  62506. /**
  62507. * Gets or sets the current interval between two checks (every 2000ms by default)
  62508. */
  62509. trackerDuration: number;
  62510. /**
  62511. * Gets the list of active optimizations
  62512. */
  62513. readonly optimizations: SceneOptimization[];
  62514. /**
  62515. * Creates a new SceneOptimizer
  62516. * @param scene defines the scene to work on
  62517. * @param options defines the options to use with the SceneOptimizer
  62518. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62519. * @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)
  62520. */
  62521. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62522. /**
  62523. * Stops the current optimizer
  62524. */
  62525. stop(): void;
  62526. /**
  62527. * Reset the optimizer to initial step (current priority level = 0)
  62528. */
  62529. reset(): void;
  62530. /**
  62531. * Start the optimizer. By default it will try to reach a specific framerate
  62532. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62533. */
  62534. start(): void;
  62535. private _checkCurrentState;
  62536. /**
  62537. * Release all resources
  62538. */
  62539. dispose(): void;
  62540. /**
  62541. * Helper function to create a SceneOptimizer with one single line of code
  62542. * @param scene defines the scene to work on
  62543. * @param options defines the options to use with the SceneOptimizer
  62544. * @param onSuccess defines a callback to call on success
  62545. * @param onFailure defines a callback to call on failure
  62546. * @returns the new SceneOptimizer object
  62547. */
  62548. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62549. }
  62550. }
  62551. declare module BABYLON {
  62552. /**
  62553. * Class used to serialize a scene into a string
  62554. */
  62555. export class SceneSerializer {
  62556. /**
  62557. * Clear cache used by a previous serialization
  62558. */
  62559. static ClearCache(): void;
  62560. /**
  62561. * Serialize a scene into a JSON compatible object
  62562. * @param scene defines the scene to serialize
  62563. * @returns a JSON compatible object
  62564. */
  62565. static Serialize(scene: Scene): any;
  62566. /**
  62567. * Serialize a mesh into a JSON compatible object
  62568. * @param toSerialize defines the mesh to serialize
  62569. * @param withParents defines if parents must be serialized as well
  62570. * @param withChildren defines if children must be serialized as well
  62571. * @returns a JSON compatible object
  62572. */
  62573. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62574. }
  62575. }
  62576. declare module BABYLON {
  62577. /**
  62578. * Class used to host texture specific utilities
  62579. */
  62580. export class TextureTools {
  62581. /**
  62582. * Uses the GPU to create a copy texture rescaled at a given size
  62583. * @param texture Texture to copy from
  62584. * @param width defines the desired width
  62585. * @param height defines the desired height
  62586. * @param useBilinearMode defines if bilinear mode has to be used
  62587. * @return the generated texture
  62588. */
  62589. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62590. }
  62591. }
  62592. declare module BABYLON {
  62593. /**
  62594. * This represents the different options available for the video capture.
  62595. */
  62596. export interface VideoRecorderOptions {
  62597. /** Defines the mime type of the video. */
  62598. mimeType: string;
  62599. /** Defines the FPS the video should be recorded at. */
  62600. fps: number;
  62601. /** Defines the chunk size for the recording data. */
  62602. recordChunckSize: number;
  62603. /** The audio tracks to attach to the recording. */
  62604. audioTracks?: MediaStreamTrack[];
  62605. }
  62606. /**
  62607. * This can help with recording videos from BabylonJS.
  62608. * This is based on the available WebRTC functionalities of the browser.
  62609. *
  62610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62611. */
  62612. export class VideoRecorder {
  62613. private static readonly _defaultOptions;
  62614. /**
  62615. * Returns whether or not the VideoRecorder is available in your browser.
  62616. * @param engine Defines the Babylon Engine.
  62617. * @returns true if supported otherwise false.
  62618. */
  62619. static IsSupported(engine: Engine): boolean;
  62620. private readonly _options;
  62621. private _canvas;
  62622. private _mediaRecorder;
  62623. private _recordedChunks;
  62624. private _fileName;
  62625. private _resolve;
  62626. private _reject;
  62627. /**
  62628. * True when a recording is already in progress.
  62629. */
  62630. readonly isRecording: boolean;
  62631. /**
  62632. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62633. * @param engine Defines the BabylonJS Engine you wish to record.
  62634. * @param options Defines options that can be used to customize the capture.
  62635. */
  62636. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62637. /**
  62638. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62639. */
  62640. stopRecording(): void;
  62641. /**
  62642. * Starts recording the canvas for a max duration specified in parameters.
  62643. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62644. * If null no automatic download will start and you can rely on the promise to get the data back.
  62645. * @param maxDuration Defines the maximum recording time in seconds.
  62646. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62647. * @return A promise callback at the end of the recording with the video data in Blob.
  62648. */
  62649. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62650. /**
  62651. * Releases internal resources used during the recording.
  62652. */
  62653. dispose(): void;
  62654. private _handleDataAvailable;
  62655. private _handleError;
  62656. private _handleStop;
  62657. }
  62658. }
  62659. declare module BABYLON {
  62660. /**
  62661. * Class containing a set of static utilities functions for screenshots
  62662. */
  62663. export class ScreenshotTools {
  62664. /**
  62665. * Captures a screenshot of the current rendering
  62666. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62667. * @param engine defines the rendering engine
  62668. * @param camera defines the source camera
  62669. * @param size This parameter can be set to a single number or to an object with the
  62670. * following (optional) properties: precision, width, height. If a single number is passed,
  62671. * it will be used for both width and height. If an object is passed, the screenshot size
  62672. * will be derived from the parameters. The precision property is a multiplier allowing
  62673. * rendering at a higher or lower resolution
  62674. * @param successCallback defines the callback receives a single parameter which contains the
  62675. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62676. * src parameter of an <img> to display it
  62677. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62678. * Check your browser for supported MIME types
  62679. */
  62680. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62681. /**
  62682. * Captures a screenshot of the current rendering
  62683. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62684. * @param engine defines the rendering engine
  62685. * @param camera defines the source camera
  62686. * @param size This parameter can be set to a single number or to an object with the
  62687. * following (optional) properties: precision, width, height. If a single number is passed,
  62688. * it will be used for both width and height. If an object is passed, the screenshot size
  62689. * will be derived from the parameters. The precision property is a multiplier allowing
  62690. * rendering at a higher or lower resolution
  62691. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62692. * Check your browser for supported MIME types
  62693. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62694. * to the src parameter of an <img> to display it
  62695. */
  62696. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62697. /**
  62698. * Generates an image screenshot from the specified camera.
  62699. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62700. * @param engine The engine to use for rendering
  62701. * @param camera The camera to use for rendering
  62702. * @param size This parameter can be set to a single number or to an object with the
  62703. * following (optional) properties: precision, width, height. If a single number is passed,
  62704. * it will be used for both width and height. If an object is passed, the screenshot size
  62705. * will be derived from the parameters. The precision property is a multiplier allowing
  62706. * rendering at a higher or lower resolution
  62707. * @param successCallback The callback receives a single parameter which contains the
  62708. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62709. * src parameter of an <img> to display it
  62710. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62711. * Check your browser for supported MIME types
  62712. * @param samples Texture samples (default: 1)
  62713. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62714. * @param fileName A name for for the downloaded file.
  62715. */
  62716. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62717. /**
  62718. * Generates an image screenshot from the specified camera.
  62719. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62720. * @param engine The engine to use for rendering
  62721. * @param camera The camera to use for rendering
  62722. * @param size This parameter can be set to a single number or to an object with the
  62723. * following (optional) properties: precision, width, height. If a single number is passed,
  62724. * it will be used for both width and height. If an object is passed, the screenshot size
  62725. * will be derived from the parameters. The precision property is a multiplier allowing
  62726. * rendering at a higher or lower resolution
  62727. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62728. * Check your browser for supported MIME types
  62729. * @param samples Texture samples (default: 1)
  62730. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62731. * @param fileName A name for for the downloaded file.
  62732. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62733. * to the src parameter of an <img> to display it
  62734. */
  62735. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62736. /**
  62737. * Gets height and width for screenshot size
  62738. * @private
  62739. */
  62740. private static _getScreenshotSize;
  62741. }
  62742. }
  62743. declare module BABYLON {
  62744. /**
  62745. * A cursor which tracks a point on a path
  62746. */
  62747. export class PathCursor {
  62748. private path;
  62749. /**
  62750. * Stores path cursor callbacks for when an onchange event is triggered
  62751. */
  62752. private _onchange;
  62753. /**
  62754. * The value of the path cursor
  62755. */
  62756. value: number;
  62757. /**
  62758. * The animation array of the path cursor
  62759. */
  62760. animations: Animation[];
  62761. /**
  62762. * Initializes the path cursor
  62763. * @param path The path to track
  62764. */
  62765. constructor(path: Path2);
  62766. /**
  62767. * Gets the cursor point on the path
  62768. * @returns A point on the path cursor at the cursor location
  62769. */
  62770. getPoint(): Vector3;
  62771. /**
  62772. * Moves the cursor ahead by the step amount
  62773. * @param step The amount to move the cursor forward
  62774. * @returns This path cursor
  62775. */
  62776. moveAhead(step?: number): PathCursor;
  62777. /**
  62778. * Moves the cursor behind by the step amount
  62779. * @param step The amount to move the cursor back
  62780. * @returns This path cursor
  62781. */
  62782. moveBack(step?: number): PathCursor;
  62783. /**
  62784. * Moves the cursor by the step amount
  62785. * If the step amount is greater than one, an exception is thrown
  62786. * @param step The amount to move the cursor
  62787. * @returns This path cursor
  62788. */
  62789. move(step: number): PathCursor;
  62790. /**
  62791. * Ensures that the value is limited between zero and one
  62792. * @returns This path cursor
  62793. */
  62794. private ensureLimits;
  62795. /**
  62796. * Runs onchange callbacks on change (used by the animation engine)
  62797. * @returns This path cursor
  62798. */
  62799. private raiseOnChange;
  62800. /**
  62801. * Executes a function on change
  62802. * @param f A path cursor onchange callback
  62803. * @returns This path cursor
  62804. */
  62805. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62806. }
  62807. }
  62808. declare module BABYLON {
  62809. /** @hidden */
  62810. export var blurPixelShader: {
  62811. name: string;
  62812. shader: string;
  62813. };
  62814. }
  62815. declare module BABYLON {
  62816. /** @hidden */
  62817. export var pointCloudVertexDeclaration: {
  62818. name: string;
  62819. shader: string;
  62820. };
  62821. }
  62822. // Mixins
  62823. interface Window {
  62824. mozIndexedDB: IDBFactory;
  62825. webkitIndexedDB: IDBFactory;
  62826. msIndexedDB: IDBFactory;
  62827. webkitURL: typeof URL;
  62828. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62829. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62830. WebGLRenderingContext: WebGLRenderingContext;
  62831. MSGesture: MSGesture;
  62832. CANNON: any;
  62833. AudioContext: AudioContext;
  62834. webkitAudioContext: AudioContext;
  62835. PointerEvent: any;
  62836. Math: Math;
  62837. Uint8Array: Uint8ArrayConstructor;
  62838. Float32Array: Float32ArrayConstructor;
  62839. mozURL: typeof URL;
  62840. msURL: typeof URL;
  62841. VRFrameData: any; // WebVR, from specs 1.1
  62842. DracoDecoderModule: any;
  62843. setImmediate(handler: (...args: any[]) => void): number;
  62844. }
  62845. interface HTMLCanvasElement {
  62846. requestPointerLock(): void;
  62847. msRequestPointerLock?(): void;
  62848. mozRequestPointerLock?(): void;
  62849. webkitRequestPointerLock?(): void;
  62850. /** Track wether a record is in progress */
  62851. isRecording: boolean;
  62852. /** Capture Stream method defined by some browsers */
  62853. captureStream(fps?: number): MediaStream;
  62854. }
  62855. interface CanvasRenderingContext2D {
  62856. msImageSmoothingEnabled: boolean;
  62857. }
  62858. interface MouseEvent {
  62859. mozMovementX: number;
  62860. mozMovementY: number;
  62861. webkitMovementX: number;
  62862. webkitMovementY: number;
  62863. msMovementX: number;
  62864. msMovementY: number;
  62865. }
  62866. interface Navigator {
  62867. mozGetVRDevices: (any: any) => any;
  62868. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62869. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62870. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62871. webkitGetGamepads(): Gamepad[];
  62872. msGetGamepads(): Gamepad[];
  62873. webkitGamepads(): Gamepad[];
  62874. }
  62875. interface HTMLVideoElement {
  62876. mozSrcObject: any;
  62877. }
  62878. interface Math {
  62879. fround(x: number): number;
  62880. imul(a: number, b: number): number;
  62881. }
  62882. interface WebGLRenderingContext {
  62883. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62884. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62885. vertexAttribDivisor(index: number, divisor: number): void;
  62886. createVertexArray(): any;
  62887. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62888. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62889. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62890. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62891. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62892. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62893. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62894. // Queries
  62895. createQuery(): WebGLQuery;
  62896. deleteQuery(query: WebGLQuery): void;
  62897. beginQuery(target: number, query: WebGLQuery): void;
  62898. endQuery(target: number): void;
  62899. getQueryParameter(query: WebGLQuery, pname: number): any;
  62900. getQuery(target: number, pname: number): any;
  62901. MAX_SAMPLES: number;
  62902. RGBA8: number;
  62903. READ_FRAMEBUFFER: number;
  62904. DRAW_FRAMEBUFFER: number;
  62905. UNIFORM_BUFFER: number;
  62906. HALF_FLOAT_OES: number;
  62907. RGBA16F: number;
  62908. RGBA32F: number;
  62909. R32F: number;
  62910. RG32F: number;
  62911. RGB32F: number;
  62912. R16F: number;
  62913. RG16F: number;
  62914. RGB16F: number;
  62915. RED: number;
  62916. RG: number;
  62917. R8: number;
  62918. RG8: number;
  62919. UNSIGNED_INT_24_8: number;
  62920. DEPTH24_STENCIL8: number;
  62921. MIN: number;
  62922. MAX: number;
  62923. /* Multiple Render Targets */
  62924. drawBuffers(buffers: number[]): void;
  62925. readBuffer(src: number): void;
  62926. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62927. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62928. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62929. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62930. // Occlusion Query
  62931. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62932. ANY_SAMPLES_PASSED: number;
  62933. QUERY_RESULT_AVAILABLE: number;
  62934. QUERY_RESULT: number;
  62935. }
  62936. interface WebGLProgram {
  62937. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62938. }
  62939. interface EXT_disjoint_timer_query {
  62940. QUERY_COUNTER_BITS_EXT: number;
  62941. TIME_ELAPSED_EXT: number;
  62942. TIMESTAMP_EXT: number;
  62943. GPU_DISJOINT_EXT: number;
  62944. QUERY_RESULT_EXT: number;
  62945. QUERY_RESULT_AVAILABLE_EXT: number;
  62946. queryCounterEXT(query: WebGLQuery, target: number): void;
  62947. createQueryEXT(): WebGLQuery;
  62948. beginQueryEXT(target: number, query: WebGLQuery): void;
  62949. endQueryEXT(target: number): void;
  62950. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62951. deleteQueryEXT(query: WebGLQuery): void;
  62952. }
  62953. interface WebGLUniformLocation {
  62954. _currentState: any;
  62955. }
  62956. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62957. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62958. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62959. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62960. interface WebGLRenderingContext {
  62961. readonly RASTERIZER_DISCARD: number;
  62962. readonly DEPTH_COMPONENT24: number;
  62963. readonly TEXTURE_3D: number;
  62964. readonly TEXTURE_2D_ARRAY: number;
  62965. readonly TEXTURE_COMPARE_FUNC: number;
  62966. readonly TEXTURE_COMPARE_MODE: number;
  62967. readonly COMPARE_REF_TO_TEXTURE: number;
  62968. readonly TEXTURE_WRAP_R: number;
  62969. readonly HALF_FLOAT: number;
  62970. readonly RGB8: number;
  62971. readonly RED_INTEGER: number;
  62972. readonly RG_INTEGER: number;
  62973. readonly RGB_INTEGER: number;
  62974. readonly RGBA_INTEGER: number;
  62975. readonly R8_SNORM: number;
  62976. readonly RG8_SNORM: number;
  62977. readonly RGB8_SNORM: number;
  62978. readonly RGBA8_SNORM: number;
  62979. readonly R8I: number;
  62980. readonly RG8I: number;
  62981. readonly RGB8I: number;
  62982. readonly RGBA8I: number;
  62983. readonly R8UI: number;
  62984. readonly RG8UI: number;
  62985. readonly RGB8UI: number;
  62986. readonly RGBA8UI: number;
  62987. readonly R16I: number;
  62988. readonly RG16I: number;
  62989. readonly RGB16I: number;
  62990. readonly RGBA16I: number;
  62991. readonly R16UI: number;
  62992. readonly RG16UI: number;
  62993. readonly RGB16UI: number;
  62994. readonly RGBA16UI: number;
  62995. readonly R32I: number;
  62996. readonly RG32I: number;
  62997. readonly RGB32I: number;
  62998. readonly RGBA32I: number;
  62999. readonly R32UI: number;
  63000. readonly RG32UI: number;
  63001. readonly RGB32UI: number;
  63002. readonly RGBA32UI: number;
  63003. readonly RGB10_A2UI: number;
  63004. readonly R11F_G11F_B10F: number;
  63005. readonly RGB9_E5: number;
  63006. readonly RGB10_A2: number;
  63007. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  63008. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  63009. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  63010. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63011. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  63012. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  63013. 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;
  63014. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  63015. readonly TRANSFORM_FEEDBACK: number;
  63016. readonly INTERLEAVED_ATTRIBS: number;
  63017. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  63018. createTransformFeedback(): WebGLTransformFeedback;
  63019. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  63020. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  63021. beginTransformFeedback(primitiveMode: number): void;
  63022. endTransformFeedback(): void;
  63023. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  63024. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63025. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63026. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  63027. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  63028. }
  63029. interface ImageBitmap {
  63030. readonly width: number;
  63031. readonly height: number;
  63032. close(): void;
  63033. }
  63034. interface WebGLQuery extends WebGLObject {
  63035. }
  63036. declare var WebGLQuery: {
  63037. prototype: WebGLQuery;
  63038. new(): WebGLQuery;
  63039. };
  63040. interface WebGLSampler extends WebGLObject {
  63041. }
  63042. declare var WebGLSampler: {
  63043. prototype: WebGLSampler;
  63044. new(): WebGLSampler;
  63045. };
  63046. interface WebGLSync extends WebGLObject {
  63047. }
  63048. declare var WebGLSync: {
  63049. prototype: WebGLSync;
  63050. new(): WebGLSync;
  63051. };
  63052. interface WebGLTransformFeedback extends WebGLObject {
  63053. }
  63054. declare var WebGLTransformFeedback: {
  63055. prototype: WebGLTransformFeedback;
  63056. new(): WebGLTransformFeedback;
  63057. };
  63058. interface WebGLVertexArrayObject extends WebGLObject {
  63059. }
  63060. declare var WebGLVertexArrayObject: {
  63061. prototype: WebGLVertexArrayObject;
  63062. new(): WebGLVertexArrayObject;
  63063. };
  63064. // Type definitions for WebVR API
  63065. // Project: https://w3c.github.io/webvr/
  63066. // Definitions by: six a <https://github.com/lostfictions>
  63067. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  63068. interface VRDisplay extends EventTarget {
  63069. /**
  63070. * Dictionary of capabilities describing the VRDisplay.
  63071. */
  63072. readonly capabilities: VRDisplayCapabilities;
  63073. /**
  63074. * z-depth defining the far plane of the eye view frustum
  63075. * enables mapping of values in the render target depth
  63076. * attachment to scene coordinates. Initially set to 10000.0.
  63077. */
  63078. depthFar: number;
  63079. /**
  63080. * z-depth defining the near plane of the eye view frustum
  63081. * enables mapping of values in the render target depth
  63082. * attachment to scene coordinates. Initially set to 0.01.
  63083. */
  63084. depthNear: number;
  63085. /**
  63086. * An identifier for this distinct VRDisplay. Used as an
  63087. * association point in the Gamepad API.
  63088. */
  63089. readonly displayId: number;
  63090. /**
  63091. * A display name, a user-readable name identifying it.
  63092. */
  63093. readonly displayName: string;
  63094. readonly isConnected: boolean;
  63095. readonly isPresenting: boolean;
  63096. /**
  63097. * If this VRDisplay supports room-scale experiences, the optional
  63098. * stage attribute contains details on the room-scale parameters.
  63099. */
  63100. readonly stageParameters: VRStageParameters | null;
  63101. /**
  63102. * Passing the value returned by `requestAnimationFrame` to
  63103. * `cancelAnimationFrame` will unregister the callback.
  63104. * @param handle Define the hanle of the request to cancel
  63105. */
  63106. cancelAnimationFrame(handle: number): void;
  63107. /**
  63108. * Stops presenting to the VRDisplay.
  63109. * @returns a promise to know when it stopped
  63110. */
  63111. exitPresent(): Promise<void>;
  63112. /**
  63113. * Return the current VREyeParameters for the given eye.
  63114. * @param whichEye Define the eye we want the parameter for
  63115. * @returns the eye parameters
  63116. */
  63117. getEyeParameters(whichEye: string): VREyeParameters;
  63118. /**
  63119. * Populates the passed VRFrameData with the information required to render
  63120. * the current frame.
  63121. * @param frameData Define the data structure to populate
  63122. * @returns true if ok otherwise false
  63123. */
  63124. getFrameData(frameData: VRFrameData): boolean;
  63125. /**
  63126. * Get the layers currently being presented.
  63127. * @returns the list of VR layers
  63128. */
  63129. getLayers(): VRLayer[];
  63130. /**
  63131. * Return a VRPose containing the future predicted pose of the VRDisplay
  63132. * when the current frame will be presented. The value returned will not
  63133. * change until JavaScript has returned control to the browser.
  63134. *
  63135. * The VRPose will contain the position, orientation, velocity,
  63136. * and acceleration of each of these properties.
  63137. * @returns the pose object
  63138. */
  63139. getPose(): VRPose;
  63140. /**
  63141. * Return the current instantaneous pose of the VRDisplay, with no
  63142. * prediction applied.
  63143. * @returns the current instantaneous pose
  63144. */
  63145. getImmediatePose(): VRPose;
  63146. /**
  63147. * The callback passed to `requestAnimationFrame` will be called
  63148. * any time a new frame should be rendered. When the VRDisplay is
  63149. * presenting the callback will be called at the native refresh
  63150. * rate of the HMD. When not presenting this function acts
  63151. * identically to how window.requestAnimationFrame acts. Content should
  63152. * make no assumptions of frame rate or vsync behavior as the HMD runs
  63153. * asynchronously from other displays and at differing refresh rates.
  63154. * @param callback Define the eaction to run next frame
  63155. * @returns the request handle it
  63156. */
  63157. requestAnimationFrame(callback: FrameRequestCallback): number;
  63158. /**
  63159. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  63160. * Repeat calls while already presenting will update the VRLayers being displayed.
  63161. * @param layers Define the list of layer to present
  63162. * @returns a promise to know when the request has been fulfilled
  63163. */
  63164. requestPresent(layers: VRLayer[]): Promise<void>;
  63165. /**
  63166. * Reset the pose for this display, treating its current position and
  63167. * orientation as the "origin/zero" values. VRPose.position,
  63168. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  63169. * updated when calling resetPose(). This should be called in only
  63170. * sitting-space experiences.
  63171. */
  63172. resetPose(): void;
  63173. /**
  63174. * The VRLayer provided to the VRDisplay will be captured and presented
  63175. * in the HMD. Calling this function has the same effect on the source
  63176. * canvas as any other operation that uses its source image, and canvases
  63177. * created without preserveDrawingBuffer set to true will be cleared.
  63178. * @param pose Define the pose to submit
  63179. */
  63180. submitFrame(pose?: VRPose): void;
  63181. }
  63182. declare var VRDisplay: {
  63183. prototype: VRDisplay;
  63184. new(): VRDisplay;
  63185. };
  63186. interface VRLayer {
  63187. leftBounds?: number[] | Float32Array | null;
  63188. rightBounds?: number[] | Float32Array | null;
  63189. source?: HTMLCanvasElement | null;
  63190. }
  63191. interface VRDisplayCapabilities {
  63192. readonly canPresent: boolean;
  63193. readonly hasExternalDisplay: boolean;
  63194. readonly hasOrientation: boolean;
  63195. readonly hasPosition: boolean;
  63196. readonly maxLayers: number;
  63197. }
  63198. interface VREyeParameters {
  63199. /** @deprecated */
  63200. readonly fieldOfView: VRFieldOfView;
  63201. readonly offset: Float32Array;
  63202. readonly renderHeight: number;
  63203. readonly renderWidth: number;
  63204. }
  63205. interface VRFieldOfView {
  63206. readonly downDegrees: number;
  63207. readonly leftDegrees: number;
  63208. readonly rightDegrees: number;
  63209. readonly upDegrees: number;
  63210. }
  63211. interface VRFrameData {
  63212. readonly leftProjectionMatrix: Float32Array;
  63213. readonly leftViewMatrix: Float32Array;
  63214. readonly pose: VRPose;
  63215. readonly rightProjectionMatrix: Float32Array;
  63216. readonly rightViewMatrix: Float32Array;
  63217. readonly timestamp: number;
  63218. }
  63219. interface VRPose {
  63220. readonly angularAcceleration: Float32Array | null;
  63221. readonly angularVelocity: Float32Array | null;
  63222. readonly linearAcceleration: Float32Array | null;
  63223. readonly linearVelocity: Float32Array | null;
  63224. readonly orientation: Float32Array | null;
  63225. readonly position: Float32Array | null;
  63226. readonly timestamp: number;
  63227. }
  63228. interface VRStageParameters {
  63229. sittingToStandingTransform?: Float32Array;
  63230. sizeX?: number;
  63231. sizeY?: number;
  63232. }
  63233. interface Navigator {
  63234. getVRDisplays(): Promise<VRDisplay[]>;
  63235. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  63236. }
  63237. interface Window {
  63238. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  63239. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  63240. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  63241. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63242. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  63243. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  63244. }
  63245. interface Gamepad {
  63246. readonly displayId: number;
  63247. }
  63248. type XRSessionMode =
  63249. | "inline"
  63250. | "immersive-vr"
  63251. | "immersive-ar";
  63252. type XRReferenceSpaceType =
  63253. | "viewer"
  63254. | "local"
  63255. | "local-floor"
  63256. | "bounded-floor"
  63257. | "unbounded";
  63258. type XREnvironmentBlendMode =
  63259. | "opaque"
  63260. | "additive"
  63261. | "alpha-blend";
  63262. type XRVisibilityState =
  63263. | "visible"
  63264. | "visible-blurred"
  63265. | "hidden";
  63266. type XRHandedness =
  63267. | "none"
  63268. | "left"
  63269. | "right";
  63270. type XRTargetRayMode =
  63271. | "gaze"
  63272. | "tracked-pointer"
  63273. | "screen";
  63274. type XREye =
  63275. | "none"
  63276. | "left"
  63277. | "right";
  63278. interface XRSpace extends EventTarget {
  63279. }
  63280. interface XRRenderState {
  63281. depthNear?: number;
  63282. depthFar?: number;
  63283. inlineVerticalFieldOfView?: number;
  63284. baseLayer?: XRWebGLLayer;
  63285. }
  63286. interface XRInputSource {
  63287. handedness: XRHandedness;
  63288. targetRayMode: XRTargetRayMode;
  63289. targetRaySpace: XRSpace;
  63290. gripSpace: XRSpace | undefined;
  63291. gamepad: Gamepad | undefined;
  63292. profiles: Array<string>;
  63293. }
  63294. interface XRSession {
  63295. addEventListener: Function;
  63296. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  63297. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  63298. requestAnimationFrame: Function;
  63299. end(): Promise<void>;
  63300. renderState: XRRenderState;
  63301. inputSources: Array<XRInputSource>;
  63302. }
  63303. interface XRReferenceSpace extends XRSpace {
  63304. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  63305. onreset: any;
  63306. }
  63307. interface XRFrame {
  63308. session: XRSession;
  63309. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  63310. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  63311. }
  63312. interface XRViewerPose extends XRPose {
  63313. views: Array<XRView>;
  63314. }
  63315. interface XRPose {
  63316. transform: XRRigidTransform;
  63317. emulatedPosition: boolean;
  63318. }
  63319. declare var XRWebGLLayer: {
  63320. prototype: XRWebGLLayer;
  63321. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  63322. };
  63323. interface XRWebGLLayer {
  63324. framebuffer: WebGLFramebuffer;
  63325. framebufferWidth: number;
  63326. framebufferHeight: number;
  63327. getViewport: Function;
  63328. }
  63329. interface XRRigidTransform {
  63330. position: DOMPointReadOnly;
  63331. orientation: DOMPointReadOnly;
  63332. matrix: Float32Array;
  63333. inverse: XRRigidTransform;
  63334. }
  63335. interface XRView {
  63336. eye: XREye;
  63337. projectionMatrix: Float32Array;
  63338. transform: XRRigidTransform;
  63339. }
  63340. interface XRInputSourceChangeEvent {
  63341. session: XRSession;
  63342. removed: Array<XRInputSource>;
  63343. added: Array<XRInputSource>;
  63344. }
  63345. /**
  63346. * @ignore
  63347. */
  63348. declare module BABYLON.GLTF2.Exporter {
  63349. }
  63350. /**
  63351. * @ignore
  63352. */
  63353. declare module BABYLON.GLTF1 {
  63354. }
  63355. declare module BABYLON.GUI {
  63356. /**
  63357. * Class used to specific a value and its associated unit
  63358. */
  63359. export class ValueAndUnit {
  63360. /** defines the unit to store */
  63361. unit: number;
  63362. /** defines a boolean indicating if the value can be negative */
  63363. negativeValueAllowed: boolean;
  63364. private _value;
  63365. private _originalUnit;
  63366. /**
  63367. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  63368. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63369. */
  63370. ignoreAdaptiveScaling: boolean;
  63371. /**
  63372. * Creates a new ValueAndUnit
  63373. * @param value defines the value to store
  63374. * @param unit defines the unit to store
  63375. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  63376. */
  63377. constructor(value: number,
  63378. /** defines the unit to store */
  63379. unit?: number,
  63380. /** defines a boolean indicating if the value can be negative */
  63381. negativeValueAllowed?: boolean);
  63382. /** Gets a boolean indicating if the value is a percentage */
  63383. readonly isPercentage: boolean;
  63384. /** Gets a boolean indicating if the value is store as pixel */
  63385. readonly isPixel: boolean;
  63386. /** Gets direct internal value */
  63387. readonly internalValue: number;
  63388. /**
  63389. * Gets value as pixel
  63390. * @param host defines the root host
  63391. * @param refValue defines the reference value for percentages
  63392. * @returns the value as pixel
  63393. */
  63394. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  63395. /**
  63396. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  63397. * @param value defines the value to store
  63398. * @param unit defines the unit to store
  63399. * @returns the current ValueAndUnit
  63400. */
  63401. updateInPlace(value: number, unit?: number): ValueAndUnit;
  63402. /**
  63403. * Gets the value accordingly to its unit
  63404. * @param host defines the root host
  63405. * @returns the value
  63406. */
  63407. getValue(host: AdvancedDynamicTexture): number;
  63408. /**
  63409. * Gets a string representation of the value
  63410. * @param host defines the root host
  63411. * @param decimals defines an optional number of decimals to display
  63412. * @returns a string
  63413. */
  63414. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  63415. /**
  63416. * Store a value parsed from a string
  63417. * @param source defines the source string
  63418. * @returns true if the value was successfully parsed
  63419. */
  63420. fromString(source: string | number): boolean;
  63421. private static _Regex;
  63422. private static _UNITMODE_PERCENTAGE;
  63423. private static _UNITMODE_PIXEL;
  63424. /** UNITMODE_PERCENTAGE */
  63425. static readonly UNITMODE_PERCENTAGE: number;
  63426. /** UNITMODE_PIXEL */
  63427. static readonly UNITMODE_PIXEL: number;
  63428. }
  63429. }
  63430. declare module BABYLON.GUI {
  63431. /**
  63432. * Define a style used by control to automatically setup properties based on a template.
  63433. * Only support font related properties so far
  63434. */
  63435. export class Style implements BABYLON.IDisposable {
  63436. private _fontFamily;
  63437. private _fontStyle;
  63438. private _fontWeight;
  63439. /** @hidden */
  63440. _host: AdvancedDynamicTexture;
  63441. /** @hidden */
  63442. _fontSize: ValueAndUnit;
  63443. /**
  63444. * BABYLON.Observable raised when the style values are changed
  63445. */
  63446. onChangedObservable: BABYLON.Observable<Style>;
  63447. /**
  63448. * Creates a new style object
  63449. * @param host defines the AdvancedDynamicTexture which hosts this style
  63450. */
  63451. constructor(host: AdvancedDynamicTexture);
  63452. /**
  63453. * Gets or sets the font size
  63454. */
  63455. fontSize: string | number;
  63456. /**
  63457. * Gets or sets the font family
  63458. */
  63459. fontFamily: string;
  63460. /**
  63461. * Gets or sets the font style
  63462. */
  63463. fontStyle: string;
  63464. /** Gets or sets font weight */
  63465. fontWeight: string;
  63466. /** Dispose all associated resources */
  63467. dispose(): void;
  63468. }
  63469. }
  63470. declare module BABYLON.GUI {
  63471. /**
  63472. * Class used to transport BABYLON.Vector2 information for pointer events
  63473. */
  63474. export class Vector2WithInfo extends BABYLON.Vector2 {
  63475. /** defines the current mouse button index */
  63476. buttonIndex: number;
  63477. /**
  63478. * Creates a new Vector2WithInfo
  63479. * @param source defines the vector2 data to transport
  63480. * @param buttonIndex defines the current mouse button index
  63481. */
  63482. constructor(source: BABYLON.Vector2,
  63483. /** defines the current mouse button index */
  63484. buttonIndex?: number);
  63485. }
  63486. /** Class used to provide 2D matrix features */
  63487. export class Matrix2D {
  63488. /** Gets the internal array of 6 floats used to store matrix data */
  63489. m: Float32Array;
  63490. /**
  63491. * Creates a new matrix
  63492. * @param m00 defines value for (0, 0)
  63493. * @param m01 defines value for (0, 1)
  63494. * @param m10 defines value for (1, 0)
  63495. * @param m11 defines value for (1, 1)
  63496. * @param m20 defines value for (2, 0)
  63497. * @param m21 defines value for (2, 1)
  63498. */
  63499. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63500. /**
  63501. * Fills the matrix from direct values
  63502. * @param m00 defines value for (0, 0)
  63503. * @param m01 defines value for (0, 1)
  63504. * @param m10 defines value for (1, 0)
  63505. * @param m11 defines value for (1, 1)
  63506. * @param m20 defines value for (2, 0)
  63507. * @param m21 defines value for (2, 1)
  63508. * @returns the current modified matrix
  63509. */
  63510. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63511. /**
  63512. * Gets matrix determinant
  63513. * @returns the determinant
  63514. */
  63515. determinant(): number;
  63516. /**
  63517. * Inverses the matrix and stores it in a target matrix
  63518. * @param result defines the target matrix
  63519. * @returns the current matrix
  63520. */
  63521. invertToRef(result: Matrix2D): Matrix2D;
  63522. /**
  63523. * Multiplies the current matrix with another one
  63524. * @param other defines the second operand
  63525. * @param result defines the target matrix
  63526. * @returns the current matrix
  63527. */
  63528. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63529. /**
  63530. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63531. * @param x defines the x coordinate to transform
  63532. * @param y defines the x coordinate to transform
  63533. * @param result defines the target vector2
  63534. * @returns the current matrix
  63535. */
  63536. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63537. /**
  63538. * Creates an identity matrix
  63539. * @returns a new matrix
  63540. */
  63541. static Identity(): Matrix2D;
  63542. /**
  63543. * Creates a translation matrix and stores it in a target matrix
  63544. * @param x defines the x coordinate of the translation
  63545. * @param y defines the y coordinate of the translation
  63546. * @param result defines the target matrix
  63547. */
  63548. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63549. /**
  63550. * Creates a scaling matrix and stores it in a target matrix
  63551. * @param x defines the x coordinate of the scaling
  63552. * @param y defines the y coordinate of the scaling
  63553. * @param result defines the target matrix
  63554. */
  63555. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63556. /**
  63557. * Creates a rotation matrix and stores it in a target matrix
  63558. * @param angle defines the rotation angle
  63559. * @param result defines the target matrix
  63560. */
  63561. static RotationToRef(angle: number, result: Matrix2D): void;
  63562. private static _TempPreTranslationMatrix;
  63563. private static _TempPostTranslationMatrix;
  63564. private static _TempRotationMatrix;
  63565. private static _TempScalingMatrix;
  63566. private static _TempCompose0;
  63567. private static _TempCompose1;
  63568. private static _TempCompose2;
  63569. /**
  63570. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63571. * @param tx defines the x coordinate of the translation
  63572. * @param ty defines the y coordinate of the translation
  63573. * @param angle defines the rotation angle
  63574. * @param scaleX defines the x coordinate of the scaling
  63575. * @param scaleY defines the y coordinate of the scaling
  63576. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63577. * @param result defines the target matrix
  63578. */
  63579. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63580. }
  63581. }
  63582. declare module BABYLON.GUI {
  63583. /**
  63584. * Class used to store 2D control sizes
  63585. */
  63586. export class Measure {
  63587. /** defines left coordinate */
  63588. left: number;
  63589. /** defines top coordinate */
  63590. top: number;
  63591. /** defines width dimension */
  63592. width: number;
  63593. /** defines height dimension */
  63594. height: number;
  63595. /**
  63596. * Creates a new measure
  63597. * @param left defines left coordinate
  63598. * @param top defines top coordinate
  63599. * @param width defines width dimension
  63600. * @param height defines height dimension
  63601. */
  63602. constructor(
  63603. /** defines left coordinate */
  63604. left: number,
  63605. /** defines top coordinate */
  63606. top: number,
  63607. /** defines width dimension */
  63608. width: number,
  63609. /** defines height dimension */
  63610. height: number);
  63611. /**
  63612. * Copy from another measure
  63613. * @param other defines the other measure to copy from
  63614. */
  63615. copyFrom(other: Measure): void;
  63616. /**
  63617. * Copy from a group of 4 floats
  63618. * @param left defines left coordinate
  63619. * @param top defines top coordinate
  63620. * @param width defines width dimension
  63621. * @param height defines height dimension
  63622. */
  63623. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63624. /**
  63625. * Computes the axis aligned bounding box measure for two given measures
  63626. * @param a Input measure
  63627. * @param b Input measure
  63628. * @param result the resulting bounding measure
  63629. */
  63630. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63631. /**
  63632. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63633. * @param transform the matrix to transform the measure before computing the AABB
  63634. * @param result the resulting AABB
  63635. */
  63636. transformToRef(transform: Matrix2D, result: Measure): void;
  63637. /**
  63638. * Check equality between this measure and another one
  63639. * @param other defines the other measures
  63640. * @returns true if both measures are equals
  63641. */
  63642. isEqualsTo(other: Measure): boolean;
  63643. /**
  63644. * Creates an empty measure
  63645. * @returns a new measure
  63646. */
  63647. static Empty(): Measure;
  63648. }
  63649. }
  63650. declare module BABYLON.GUI {
  63651. /**
  63652. * Interface used to define a control that can receive focus
  63653. */
  63654. export interface IFocusableControl {
  63655. /**
  63656. * Function called when the control receives the focus
  63657. */
  63658. onFocus(): void;
  63659. /**
  63660. * Function called when the control loses the focus
  63661. */
  63662. onBlur(): void;
  63663. /**
  63664. * Function called to let the control handle keyboard events
  63665. * @param evt defines the current keyboard event
  63666. */
  63667. processKeyboard(evt: KeyboardEvent): void;
  63668. /**
  63669. * Function called to get the list of controls that should not steal the focus from this control
  63670. * @returns an array of controls
  63671. */
  63672. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63673. }
  63674. /**
  63675. * Class used to create texture to support 2D GUI elements
  63676. * @see http://doc.babylonjs.com/how_to/gui
  63677. */
  63678. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63679. private _isDirty;
  63680. private _renderObserver;
  63681. private _resizeObserver;
  63682. private _preKeyboardObserver;
  63683. private _pointerMoveObserver;
  63684. private _pointerObserver;
  63685. private _canvasPointerOutObserver;
  63686. private _background;
  63687. /** @hidden */
  63688. _rootContainer: Container;
  63689. /** @hidden */
  63690. _lastPickedControl: Control;
  63691. /** @hidden */
  63692. _lastControlOver: {
  63693. [pointerId: number]: Control;
  63694. };
  63695. /** @hidden */
  63696. _lastControlDown: {
  63697. [pointerId: number]: Control;
  63698. };
  63699. /** @hidden */
  63700. _capturingControl: {
  63701. [pointerId: number]: Control;
  63702. };
  63703. /** @hidden */
  63704. _shouldBlockPointer: boolean;
  63705. /** @hidden */
  63706. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63707. /** @hidden */
  63708. _linkedControls: Control[];
  63709. private _isFullscreen;
  63710. private _fullscreenViewport;
  63711. private _idealWidth;
  63712. private _idealHeight;
  63713. private _useSmallestIdeal;
  63714. private _renderAtIdealSize;
  63715. private _focusedControl;
  63716. private _blockNextFocusCheck;
  63717. private _renderScale;
  63718. private _rootCanvas;
  63719. private _cursorChanged;
  63720. /**
  63721. * Define type to string to ensure compatibility across browsers
  63722. * Safari doesn't support DataTransfer constructor
  63723. */
  63724. private _clipboardData;
  63725. /**
  63726. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63727. */
  63728. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63729. /**
  63730. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63731. */
  63732. onControlPickedObservable: BABYLON.Observable<Control>;
  63733. /**
  63734. * BABYLON.Observable event triggered before layout is evaluated
  63735. */
  63736. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63737. /**
  63738. * BABYLON.Observable event triggered after the layout was evaluated
  63739. */
  63740. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63741. /**
  63742. * BABYLON.Observable event triggered before the texture is rendered
  63743. */
  63744. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63745. /**
  63746. * BABYLON.Observable event triggered after the texture was rendered
  63747. */
  63748. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63749. /**
  63750. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63751. */
  63752. premulAlpha: boolean;
  63753. /**
  63754. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63755. * Useful when you want more antialiasing
  63756. */
  63757. renderScale: number;
  63758. /** Gets or sets the background color */
  63759. background: string;
  63760. /**
  63761. * Gets or sets the ideal width used to design controls.
  63762. * The GUI will then rescale everything accordingly
  63763. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63764. */
  63765. idealWidth: number;
  63766. /**
  63767. * Gets or sets the ideal height used to design controls.
  63768. * The GUI will then rescale everything accordingly
  63769. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63770. */
  63771. idealHeight: number;
  63772. /**
  63773. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63774. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63775. */
  63776. useSmallestIdeal: boolean;
  63777. /**
  63778. * Gets or sets a boolean indicating if adaptive scaling must be used
  63779. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63780. */
  63781. renderAtIdealSize: boolean;
  63782. /**
  63783. * Gets the underlying layer used to render the texture when in fullscreen mode
  63784. */
  63785. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63786. /**
  63787. * Gets the root container control
  63788. */
  63789. readonly rootContainer: Container;
  63790. /**
  63791. * Returns an array containing the root container.
  63792. * This is mostly used to let the Inspector introspects the ADT
  63793. * @returns an array containing the rootContainer
  63794. */
  63795. getChildren(): Array<Container>;
  63796. /**
  63797. * Will return all controls that are inside this texture
  63798. * @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
  63799. * @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
  63800. * @return all child controls
  63801. */
  63802. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63803. /**
  63804. * Gets or sets the current focused control
  63805. */
  63806. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63807. /**
  63808. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63809. */
  63810. isForeground: boolean;
  63811. /**
  63812. * Gets or set information about clipboardData
  63813. */
  63814. clipboardData: string;
  63815. /**
  63816. * Creates a new AdvancedDynamicTexture
  63817. * @param name defines the name of the texture
  63818. * @param width defines the width of the texture
  63819. * @param height defines the height of the texture
  63820. * @param scene defines the hosting scene
  63821. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63822. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63823. */
  63824. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63825. /**
  63826. * Get the current class name of the texture useful for serialization or dynamic coding.
  63827. * @returns "AdvancedDynamicTexture"
  63828. */
  63829. getClassName(): string;
  63830. /**
  63831. * Function used to execute a function on all controls
  63832. * @param func defines the function to execute
  63833. * @param container defines the container where controls belong. If null the root container will be used
  63834. */
  63835. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63836. private _useInvalidateRectOptimization;
  63837. /**
  63838. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63839. */
  63840. useInvalidateRectOptimization: boolean;
  63841. private _invalidatedRectangle;
  63842. /**
  63843. * Invalidates a rectangle area on the gui texture
  63844. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63845. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63846. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63847. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63848. */
  63849. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63850. /**
  63851. * Marks the texture as dirty forcing a complete update
  63852. */
  63853. markAsDirty(): void;
  63854. /**
  63855. * Helper function used to create a new style
  63856. * @returns a new style
  63857. * @see http://doc.babylonjs.com/how_to/gui#styles
  63858. */
  63859. createStyle(): Style;
  63860. /**
  63861. * Adds a new control to the root container
  63862. * @param control defines the control to add
  63863. * @returns the current texture
  63864. */
  63865. addControl(control: Control): AdvancedDynamicTexture;
  63866. /**
  63867. * Removes a control from the root container
  63868. * @param control defines the control to remove
  63869. * @returns the current texture
  63870. */
  63871. removeControl(control: Control): AdvancedDynamicTexture;
  63872. /**
  63873. * Release all resources
  63874. */
  63875. dispose(): void;
  63876. private _onResize;
  63877. /** @hidden */
  63878. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63879. /**
  63880. * Get screen coordinates for a vector3
  63881. * @param position defines the position to project
  63882. * @param worldMatrix defines the world matrix to use
  63883. * @returns the projected position
  63884. */
  63885. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63886. private _checkUpdate;
  63887. private _clearMeasure;
  63888. private _render;
  63889. /** @hidden */
  63890. _changeCursor(cursor: string): void;
  63891. /** @hidden */
  63892. _registerLastControlDown(control: Control, pointerId: number): void;
  63893. private _doPicking;
  63894. /** @hidden */
  63895. _cleanControlAfterRemovalFromList(list: {
  63896. [pointerId: number]: Control;
  63897. }, control: Control): void;
  63898. /** @hidden */
  63899. _cleanControlAfterRemoval(control: Control): void;
  63900. /** Attach to all scene events required to support pointer events */
  63901. attach(): void;
  63902. /** @hidden */
  63903. private onClipboardCopy;
  63904. /** @hidden */
  63905. private onClipboardCut;
  63906. /** @hidden */
  63907. private onClipboardPaste;
  63908. /**
  63909. * Register the clipboard Events onto the canvas
  63910. */
  63911. registerClipboardEvents(): void;
  63912. /**
  63913. * Unregister the clipboard Events from the canvas
  63914. */
  63915. unRegisterClipboardEvents(): void;
  63916. /**
  63917. * Connect the texture to a hosting mesh to enable interactions
  63918. * @param mesh defines the mesh to attach to
  63919. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63920. */
  63921. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63922. /**
  63923. * Move the focus to a specific control
  63924. * @param control defines the control which will receive the focus
  63925. */
  63926. moveFocusToControl(control: IFocusableControl): void;
  63927. private _manageFocus;
  63928. private _attachToOnPointerOut;
  63929. /**
  63930. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63931. * @param mesh defines the mesh which will receive the texture
  63932. * @param width defines the texture width (1024 by default)
  63933. * @param height defines the texture height (1024 by default)
  63934. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63935. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63936. * @returns a new AdvancedDynamicTexture
  63937. */
  63938. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63939. /**
  63940. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63941. * In this mode the texture will rely on a layer for its rendering.
  63942. * This allows it to be treated like any other layer.
  63943. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63944. * LayerMask is set through advancedTexture.layer.layerMask
  63945. * @param name defines name for the texture
  63946. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63947. * @param scene defines the hsoting scene
  63948. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63949. * @returns a new AdvancedDynamicTexture
  63950. */
  63951. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63952. }
  63953. }
  63954. declare module BABYLON.GUI {
  63955. /**
  63956. * Root class used for all 2D controls
  63957. * @see http://doc.babylonjs.com/how_to/gui#controls
  63958. */
  63959. export class Control {
  63960. /** defines the name of the control */
  63961. name?: string | undefined;
  63962. /**
  63963. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63964. */
  63965. static AllowAlphaInheritance: boolean;
  63966. private _alpha;
  63967. private _alphaSet;
  63968. private _zIndex;
  63969. /** @hidden */
  63970. _host: AdvancedDynamicTexture;
  63971. /** Gets or sets the control parent */
  63972. parent: BABYLON.Nullable<Container>;
  63973. /** @hidden */
  63974. _currentMeasure: Measure;
  63975. private _fontFamily;
  63976. private _fontStyle;
  63977. private _fontWeight;
  63978. private _fontSize;
  63979. private _font;
  63980. /** @hidden */
  63981. _width: ValueAndUnit;
  63982. /** @hidden */
  63983. _height: ValueAndUnit;
  63984. /** @hidden */
  63985. protected _fontOffset: {
  63986. ascent: number;
  63987. height: number;
  63988. descent: number;
  63989. };
  63990. private _color;
  63991. private _style;
  63992. private _styleObserver;
  63993. /** @hidden */
  63994. protected _horizontalAlignment: number;
  63995. /** @hidden */
  63996. protected _verticalAlignment: number;
  63997. /** @hidden */
  63998. protected _isDirty: boolean;
  63999. /** @hidden */
  64000. protected _wasDirty: boolean;
  64001. /** @hidden */
  64002. _tempParentMeasure: Measure;
  64003. /** @hidden */
  64004. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  64005. /** @hidden */
  64006. protected _cachedParentMeasure: Measure;
  64007. private _paddingLeft;
  64008. private _paddingRight;
  64009. private _paddingTop;
  64010. private _paddingBottom;
  64011. /** @hidden */
  64012. _left: ValueAndUnit;
  64013. /** @hidden */
  64014. _top: ValueAndUnit;
  64015. private _scaleX;
  64016. private _scaleY;
  64017. private _rotation;
  64018. private _transformCenterX;
  64019. private _transformCenterY;
  64020. /** @hidden */
  64021. _transformMatrix: Matrix2D;
  64022. /** @hidden */
  64023. protected _invertTransformMatrix: Matrix2D;
  64024. /** @hidden */
  64025. protected _transformedPosition: BABYLON.Vector2;
  64026. private _isMatrixDirty;
  64027. private _cachedOffsetX;
  64028. private _cachedOffsetY;
  64029. private _isVisible;
  64030. private _isHighlighted;
  64031. /** @hidden */
  64032. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64033. private _fontSet;
  64034. private _dummyVector2;
  64035. private _downCount;
  64036. private _enterCount;
  64037. private _doNotRender;
  64038. private _downPointerIds;
  64039. protected _isEnabled: boolean;
  64040. protected _disabledColor: string;
  64041. /** @hidden */
  64042. protected _rebuildLayout: boolean;
  64043. /** @hidden */
  64044. _isClipped: boolean;
  64045. /** @hidden */
  64046. _tag: any;
  64047. /**
  64048. * 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
  64049. */
  64050. uniqueId: number;
  64051. /**
  64052. * Gets or sets an object used to store user defined information for the node
  64053. */
  64054. metadata: any;
  64055. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  64056. isHitTestVisible: boolean;
  64057. /** Gets or sets a boolean indicating if the control can block pointer events */
  64058. isPointerBlocker: boolean;
  64059. /** Gets or sets a boolean indicating if the control can be focusable */
  64060. isFocusInvisible: boolean;
  64061. /**
  64062. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  64063. * 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
  64064. */
  64065. clipChildren: boolean;
  64066. /**
  64067. * Gets or sets a boolean indicating that control content must be clipped
  64068. * 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
  64069. */
  64070. clipContent: boolean;
  64071. /**
  64072. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  64073. */
  64074. useBitmapCache: boolean;
  64075. private _cacheData;
  64076. private _shadowOffsetX;
  64077. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  64078. shadowOffsetX: number;
  64079. private _shadowOffsetY;
  64080. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  64081. shadowOffsetY: number;
  64082. private _shadowBlur;
  64083. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  64084. shadowBlur: number;
  64085. private _shadowColor;
  64086. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  64087. shadowColor: string;
  64088. /** Gets or sets the cursor to use when the control is hovered */
  64089. hoverCursor: string;
  64090. /** @hidden */
  64091. protected _linkOffsetX: ValueAndUnit;
  64092. /** @hidden */
  64093. protected _linkOffsetY: ValueAndUnit;
  64094. /** Gets the control type name */
  64095. readonly typeName: string;
  64096. /**
  64097. * Get the current class name of the control.
  64098. * @returns current class name
  64099. */
  64100. getClassName(): string;
  64101. /**
  64102. * An event triggered when the pointer move over the control.
  64103. */
  64104. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  64105. /**
  64106. * An event triggered when the pointer move out of the control.
  64107. */
  64108. onPointerOutObservable: BABYLON.Observable<Control>;
  64109. /**
  64110. * An event triggered when the pointer taps the control
  64111. */
  64112. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  64113. /**
  64114. * An event triggered when pointer up
  64115. */
  64116. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  64117. /**
  64118. * An event triggered when a control is clicked on
  64119. */
  64120. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  64121. /**
  64122. * An event triggered when pointer enters the control
  64123. */
  64124. onPointerEnterObservable: BABYLON.Observable<Control>;
  64125. /**
  64126. * An event triggered when the control is marked as dirty
  64127. */
  64128. onDirtyObservable: BABYLON.Observable<Control>;
  64129. /**
  64130. * An event triggered before drawing the control
  64131. */
  64132. onBeforeDrawObservable: BABYLON.Observable<Control>;
  64133. /**
  64134. * An event triggered after the control was drawn
  64135. */
  64136. onAfterDrawObservable: BABYLON.Observable<Control>;
  64137. /**
  64138. * Get the hosting AdvancedDynamicTexture
  64139. */
  64140. readonly host: AdvancedDynamicTexture;
  64141. /** Gets or set information about font offsets (used to render and align text) */
  64142. fontOffset: {
  64143. ascent: number;
  64144. height: number;
  64145. descent: number;
  64146. };
  64147. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  64148. alpha: number;
  64149. /**
  64150. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  64151. */
  64152. isHighlighted: boolean;
  64153. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  64154. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64155. */
  64156. scaleX: number;
  64157. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  64158. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64159. */
  64160. scaleY: number;
  64161. /** Gets or sets the rotation angle (0 by default)
  64162. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64163. */
  64164. rotation: number;
  64165. /** Gets or sets the transformation center on Y axis (0 by default)
  64166. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64167. */
  64168. transformCenterY: number;
  64169. /** Gets or sets the transformation center on X axis (0 by default)
  64170. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  64171. */
  64172. transformCenterX: number;
  64173. /**
  64174. * Gets or sets the horizontal alignment
  64175. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64176. */
  64177. horizontalAlignment: number;
  64178. /**
  64179. * Gets or sets the vertical alignment
  64180. * @see http://doc.babylonjs.com/how_to/gui#alignments
  64181. */
  64182. verticalAlignment: number;
  64183. /**
  64184. * Gets or sets control width
  64185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64186. */
  64187. width: string | number;
  64188. /**
  64189. * Gets or sets the control width in pixel
  64190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64191. */
  64192. widthInPixels: number;
  64193. /**
  64194. * Gets or sets control height
  64195. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64196. */
  64197. height: string | number;
  64198. /**
  64199. * Gets or sets control height in pixel
  64200. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64201. */
  64202. heightInPixels: number;
  64203. /** Gets or set font family */
  64204. fontFamily: string;
  64205. /** Gets or sets font style */
  64206. fontStyle: string;
  64207. /** Gets or sets font weight */
  64208. fontWeight: string;
  64209. /**
  64210. * Gets or sets style
  64211. * @see http://doc.babylonjs.com/how_to/gui#styles
  64212. */
  64213. style: BABYLON.Nullable<Style>;
  64214. /** @hidden */
  64215. readonly _isFontSizeInPercentage: boolean;
  64216. /** Gets or sets font size in pixels */
  64217. fontSizeInPixels: number;
  64218. /** Gets or sets font size */
  64219. fontSize: string | number;
  64220. /** Gets or sets foreground color */
  64221. color: string;
  64222. /** Gets or sets z index which is used to reorder controls on the z axis */
  64223. zIndex: number;
  64224. /** Gets or sets a boolean indicating if the control can be rendered */
  64225. notRenderable: boolean;
  64226. /** Gets or sets a boolean indicating if the control is visible */
  64227. isVisible: boolean;
  64228. /** Gets a boolean indicating that the control needs to update its rendering */
  64229. readonly isDirty: boolean;
  64230. /**
  64231. * Gets the current linked mesh (or null if none)
  64232. */
  64233. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  64234. /**
  64235. * Gets or sets a value indicating the padding to use on the left of the control
  64236. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64237. */
  64238. paddingLeft: string | number;
  64239. /**
  64240. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  64241. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64242. */
  64243. paddingLeftInPixels: number;
  64244. /**
  64245. * Gets or sets a value indicating the padding to use on the right of the control
  64246. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64247. */
  64248. paddingRight: string | number;
  64249. /**
  64250. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  64251. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64252. */
  64253. paddingRightInPixels: number;
  64254. /**
  64255. * Gets or sets a value indicating the padding to use on the top of the control
  64256. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64257. */
  64258. paddingTop: string | number;
  64259. /**
  64260. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  64261. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64262. */
  64263. paddingTopInPixels: number;
  64264. /**
  64265. * Gets or sets a value indicating the padding to use on the bottom of the control
  64266. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64267. */
  64268. paddingBottom: string | number;
  64269. /**
  64270. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  64271. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64272. */
  64273. paddingBottomInPixels: number;
  64274. /**
  64275. * Gets or sets a value indicating the left coordinate of the control
  64276. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64277. */
  64278. left: string | number;
  64279. /**
  64280. * Gets or sets a value indicating the left coordinate in pixels of the control
  64281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64282. */
  64283. leftInPixels: number;
  64284. /**
  64285. * Gets or sets a value indicating the top coordinate of the control
  64286. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64287. */
  64288. top: string | number;
  64289. /**
  64290. * Gets or sets a value indicating the top coordinate in pixels of the control
  64291. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64292. */
  64293. topInPixels: number;
  64294. /**
  64295. * Gets or sets a value indicating the offset on X axis to the linked mesh
  64296. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64297. */
  64298. linkOffsetX: string | number;
  64299. /**
  64300. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  64301. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64302. */
  64303. linkOffsetXInPixels: number;
  64304. /**
  64305. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  64306. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64307. */
  64308. linkOffsetY: string | number;
  64309. /**
  64310. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  64311. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64312. */
  64313. linkOffsetYInPixels: number;
  64314. /** Gets the center coordinate on X axis */
  64315. readonly centerX: number;
  64316. /** Gets the center coordinate on Y axis */
  64317. readonly centerY: number;
  64318. /** Gets or sets if control is Enabled*/
  64319. isEnabled: boolean;
  64320. /** Gets or sets background color of control if it's disabled*/
  64321. disabledColor: string;
  64322. /**
  64323. * Creates a new control
  64324. * @param name defines the name of the control
  64325. */
  64326. constructor(
  64327. /** defines the name of the control */
  64328. name?: string | undefined);
  64329. /** @hidden */
  64330. protected _getTypeName(): string;
  64331. /**
  64332. * Gets the first ascendant in the hierarchy of the given type
  64333. * @param className defines the required type
  64334. * @returns the ascendant or null if not found
  64335. */
  64336. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  64337. /** @hidden */
  64338. _resetFontCache(): void;
  64339. /**
  64340. * Determines if a container is an ascendant of the current control
  64341. * @param container defines the container to look for
  64342. * @returns true if the container is one of the ascendant of the control
  64343. */
  64344. isAscendant(container: Control): boolean;
  64345. /**
  64346. * Gets coordinates in local control space
  64347. * @param globalCoordinates defines the coordinates to transform
  64348. * @returns the new coordinates in local space
  64349. */
  64350. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64351. /**
  64352. * Gets coordinates in local control space
  64353. * @param globalCoordinates defines the coordinates to transform
  64354. * @param result defines the target vector2 where to store the result
  64355. * @returns the current control
  64356. */
  64357. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  64358. /**
  64359. * Gets coordinates in parent local control space
  64360. * @param globalCoordinates defines the coordinates to transform
  64361. * @returns the new coordinates in parent local space
  64362. */
  64363. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  64364. /**
  64365. * Move the current control to a vector3 position projected onto the screen.
  64366. * @param position defines the target position
  64367. * @param scene defines the hosting scene
  64368. */
  64369. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  64370. /** @hidden */
  64371. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64372. /**
  64373. * Will return all controls that have this control as ascendant
  64374. * @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
  64375. * @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
  64376. * @return all child controls
  64377. */
  64378. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  64379. /**
  64380. * Link current control with a target mesh
  64381. * @param mesh defines the mesh to link with
  64382. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  64383. */
  64384. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  64385. /** @hidden */
  64386. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  64387. /** @hidden */
  64388. _offsetLeft(offset: number): void;
  64389. /** @hidden */
  64390. _offsetTop(offset: number): void;
  64391. /** @hidden */
  64392. _markMatrixAsDirty(): void;
  64393. /** @hidden */
  64394. _flagDescendantsAsMatrixDirty(): void;
  64395. /** @hidden */
  64396. _intersectsRect(rect: Measure): boolean;
  64397. /** @hidden */
  64398. protected invalidateRect(): void;
  64399. /** @hidden */
  64400. _markAsDirty(force?: boolean): void;
  64401. /** @hidden */
  64402. _markAllAsDirty(): void;
  64403. /** @hidden */
  64404. _link(host: AdvancedDynamicTexture): void;
  64405. /** @hidden */
  64406. protected _transform(context?: CanvasRenderingContext2D): void;
  64407. /** @hidden */
  64408. _renderHighlight(context: CanvasRenderingContext2D): void;
  64409. /** @hidden */
  64410. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64411. /** @hidden */
  64412. protected _applyStates(context: CanvasRenderingContext2D): void;
  64413. /** @hidden */
  64414. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64415. /** @hidden */
  64416. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64417. protected _evaluateClippingState(parentMeasure: Measure): void;
  64418. /** @hidden */
  64419. _measure(): void;
  64420. /** @hidden */
  64421. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64422. /** @hidden */
  64423. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64424. /** @hidden */
  64425. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64426. /** @hidden */
  64427. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64428. private static _ClipMeasure;
  64429. private _tmpMeasureA;
  64430. private _clip;
  64431. /** @hidden */
  64432. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  64433. /** @hidden */
  64434. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  64435. /**
  64436. * Tests if a given coordinates belong to the current control
  64437. * @param x defines x coordinate to test
  64438. * @param y defines y coordinate to test
  64439. * @returns true if the coordinates are inside the control
  64440. */
  64441. contains(x: number, y: number): boolean;
  64442. /** @hidden */
  64443. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64444. /** @hidden */
  64445. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  64446. /** @hidden */
  64447. _onPointerEnter(target: Control): boolean;
  64448. /** @hidden */
  64449. _onPointerOut(target: Control, force?: boolean): void;
  64450. /** @hidden */
  64451. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64452. /** @hidden */
  64453. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64454. /** @hidden */
  64455. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  64456. /** @hidden */
  64457. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  64458. private _prepareFont;
  64459. /** Releases associated resources */
  64460. dispose(): void;
  64461. private static _HORIZONTAL_ALIGNMENT_LEFT;
  64462. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  64463. private static _HORIZONTAL_ALIGNMENT_CENTER;
  64464. private static _VERTICAL_ALIGNMENT_TOP;
  64465. private static _VERTICAL_ALIGNMENT_BOTTOM;
  64466. private static _VERTICAL_ALIGNMENT_CENTER;
  64467. /** HORIZONTAL_ALIGNMENT_LEFT */
  64468. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  64469. /** HORIZONTAL_ALIGNMENT_RIGHT */
  64470. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  64471. /** HORIZONTAL_ALIGNMENT_CENTER */
  64472. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  64473. /** VERTICAL_ALIGNMENT_TOP */
  64474. static readonly VERTICAL_ALIGNMENT_TOP: number;
  64475. /** VERTICAL_ALIGNMENT_BOTTOM */
  64476. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  64477. /** VERTICAL_ALIGNMENT_CENTER */
  64478. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  64479. private static _FontHeightSizes;
  64480. /** @hidden */
  64481. static _GetFontOffset(font: string): {
  64482. ascent: number;
  64483. height: number;
  64484. descent: number;
  64485. };
  64486. /**
  64487. * Creates a stack panel that can be used to render headers
  64488. * @param control defines the control to associate with the header
  64489. * @param text defines the text of the header
  64490. * @param size defines the size of the header
  64491. * @param options defines options used to configure the header
  64492. * @returns a new StackPanel
  64493. * @ignore
  64494. * @hidden
  64495. */
  64496. static AddHeader: (control: Control, text: string, size: string | number, options: {
  64497. isHorizontal: boolean;
  64498. controlFirst: boolean;
  64499. }) => any;
  64500. /** @hidden */
  64501. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  64502. }
  64503. }
  64504. declare module BABYLON.GUI {
  64505. /**
  64506. * Root class for 2D containers
  64507. * @see http://doc.babylonjs.com/how_to/gui#containers
  64508. */
  64509. export class Container extends Control {
  64510. name?: string | undefined;
  64511. /** @hidden */
  64512. protected _children: Control[];
  64513. /** @hidden */
  64514. protected _measureForChildren: Measure;
  64515. /** @hidden */
  64516. protected _background: string;
  64517. /** @hidden */
  64518. protected _adaptWidthToChildren: boolean;
  64519. /** @hidden */
  64520. protected _adaptHeightToChildren: boolean;
  64521. /**
  64522. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  64523. */
  64524. logLayoutCycleErrors: boolean;
  64525. /**
  64526. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  64527. */
  64528. maxLayoutCycle: number;
  64529. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  64530. adaptHeightToChildren: boolean;
  64531. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  64532. adaptWidthToChildren: boolean;
  64533. /** Gets or sets background color */
  64534. background: string;
  64535. /** Gets the list of children */
  64536. readonly children: Control[];
  64537. /**
  64538. * Creates a new Container
  64539. * @param name defines the name of the container
  64540. */
  64541. constructor(name?: string | undefined);
  64542. protected _getTypeName(): string;
  64543. _flagDescendantsAsMatrixDirty(): void;
  64544. /**
  64545. * Gets a child using its name
  64546. * @param name defines the child name to look for
  64547. * @returns the child control if found
  64548. */
  64549. getChildByName(name: string): BABYLON.Nullable<Control>;
  64550. /**
  64551. * Gets a child using its type and its name
  64552. * @param name defines the child name to look for
  64553. * @param type defines the child type to look for
  64554. * @returns the child control if found
  64555. */
  64556. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64557. /**
  64558. * Search for a specific control in children
  64559. * @param control defines the control to look for
  64560. * @returns true if the control is in child list
  64561. */
  64562. containsControl(control: Control): boolean;
  64563. /**
  64564. * Adds a new control to the current container
  64565. * @param control defines the control to add
  64566. * @returns the current container
  64567. */
  64568. addControl(control: BABYLON.Nullable<Control>): Container;
  64569. /**
  64570. * Removes all controls from the current container
  64571. * @returns the current container
  64572. */
  64573. clearControls(): Container;
  64574. /**
  64575. * Removes a control from the current container
  64576. * @param control defines the control to remove
  64577. * @returns the current container
  64578. */
  64579. removeControl(control: Control): Container;
  64580. /** @hidden */
  64581. _reOrderControl(control: Control): void;
  64582. /** @hidden */
  64583. _offsetLeft(offset: number): void;
  64584. /** @hidden */
  64585. _offsetTop(offset: number): void;
  64586. /** @hidden */
  64587. _markAllAsDirty(): void;
  64588. /** @hidden */
  64589. protected _localDraw(context: CanvasRenderingContext2D): void;
  64590. /** @hidden */
  64591. _link(host: AdvancedDynamicTexture): void;
  64592. /** @hidden */
  64593. protected _beforeLayout(): void;
  64594. /** @hidden */
  64595. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64596. /** @hidden */
  64597. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64598. protected _postMeasure(): void;
  64599. /** @hidden */
  64600. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64601. /** @hidden */
  64602. _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64603. /** @hidden */
  64604. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64605. /** @hidden */
  64606. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64607. /** Releases associated resources */
  64608. dispose(): void;
  64609. }
  64610. }
  64611. declare module BABYLON.GUI {
  64612. /** Class used to create rectangle container */
  64613. export class Rectangle extends Container {
  64614. name?: string | undefined;
  64615. private _thickness;
  64616. private _cornerRadius;
  64617. /** Gets or sets border thickness */
  64618. thickness: number;
  64619. /** Gets or sets the corner radius angle */
  64620. cornerRadius: number;
  64621. /**
  64622. * Creates a new Rectangle
  64623. * @param name defines the control name
  64624. */
  64625. constructor(name?: string | undefined);
  64626. protected _getTypeName(): string;
  64627. protected _localDraw(context: CanvasRenderingContext2D): void;
  64628. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64629. private _drawRoundedRect;
  64630. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64631. }
  64632. }
  64633. declare module BABYLON.GUI {
  64634. /**
  64635. * Enum that determines the text-wrapping mode to use.
  64636. */
  64637. export enum TextWrapping {
  64638. /**
  64639. * Clip the text when it's larger than Control.width; this is the default mode.
  64640. */
  64641. Clip = 0,
  64642. /**
  64643. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64644. */
  64645. WordWrap = 1,
  64646. /**
  64647. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64648. */
  64649. Ellipsis = 2
  64650. }
  64651. /**
  64652. * Class used to create text block control
  64653. */
  64654. export class TextBlock extends Control {
  64655. /**
  64656. * Defines the name of the control
  64657. */
  64658. name?: string | undefined;
  64659. private _text;
  64660. private _textWrapping;
  64661. private _textHorizontalAlignment;
  64662. private _textVerticalAlignment;
  64663. private _lines;
  64664. private _resizeToFit;
  64665. private _lineSpacing;
  64666. private _outlineWidth;
  64667. private _outlineColor;
  64668. /**
  64669. * An event triggered after the text is changed
  64670. */
  64671. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64672. /**
  64673. * An event triggered after the text was broken up into lines
  64674. */
  64675. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64676. /**
  64677. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64678. */
  64679. readonly lines: any[];
  64680. /**
  64681. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64682. */
  64683. /**
  64684. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64685. */
  64686. resizeToFit: boolean;
  64687. /**
  64688. * Gets or sets a boolean indicating if text must be wrapped
  64689. */
  64690. /**
  64691. * Gets or sets a boolean indicating if text must be wrapped
  64692. */
  64693. textWrapping: TextWrapping | boolean;
  64694. /**
  64695. * Gets or sets text to display
  64696. */
  64697. /**
  64698. * Gets or sets text to display
  64699. */
  64700. text: string;
  64701. /**
  64702. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64703. */
  64704. /**
  64705. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64706. */
  64707. textHorizontalAlignment: number;
  64708. /**
  64709. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64710. */
  64711. /**
  64712. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64713. */
  64714. textVerticalAlignment: number;
  64715. /**
  64716. * Gets or sets line spacing value
  64717. */
  64718. /**
  64719. * Gets or sets line spacing value
  64720. */
  64721. lineSpacing: string | number;
  64722. /**
  64723. * Gets or sets outlineWidth of the text to display
  64724. */
  64725. /**
  64726. * Gets or sets outlineWidth of the text to display
  64727. */
  64728. outlineWidth: number;
  64729. /**
  64730. * Gets or sets outlineColor of the text to display
  64731. */
  64732. /**
  64733. * Gets or sets outlineColor of the text to display
  64734. */
  64735. outlineColor: string;
  64736. /**
  64737. * Creates a new TextBlock object
  64738. * @param name defines the name of the control
  64739. * @param text defines the text to display (emptry string by default)
  64740. */
  64741. constructor(
  64742. /**
  64743. * Defines the name of the control
  64744. */
  64745. name?: string | undefined, text?: string);
  64746. protected _getTypeName(): string;
  64747. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64748. private _drawText;
  64749. /** @hidden */
  64750. _draw(context: CanvasRenderingContext2D): void;
  64751. protected _applyStates(context: CanvasRenderingContext2D): void;
  64752. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64753. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64754. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64755. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64756. protected _renderLines(context: CanvasRenderingContext2D): void;
  64757. /**
  64758. * Given a width constraint applied on the text block, find the expected height
  64759. * @returns expected height
  64760. */
  64761. computeExpectedHeight(): number;
  64762. dispose(): void;
  64763. }
  64764. }
  64765. declare module BABYLON.GUI {
  64766. /**
  64767. * Class used to create 2D images
  64768. */
  64769. export class Image extends Control {
  64770. name?: string | undefined;
  64771. private static _WorkingCanvas;
  64772. private _domImage;
  64773. private _imageWidth;
  64774. private _imageHeight;
  64775. private _loaded;
  64776. private _stretch;
  64777. private _source;
  64778. private _autoScale;
  64779. private _sourceLeft;
  64780. private _sourceTop;
  64781. private _sourceWidth;
  64782. private _sourceHeight;
  64783. private _cellWidth;
  64784. private _cellHeight;
  64785. private _cellId;
  64786. private _populateNinePatchSlicesFromImage;
  64787. private _sliceLeft;
  64788. private _sliceRight;
  64789. private _sliceTop;
  64790. private _sliceBottom;
  64791. private _detectPointerOnOpaqueOnly;
  64792. /**
  64793. * BABYLON.Observable notified when the content is loaded
  64794. */
  64795. onImageLoadedObservable: BABYLON.Observable<Image>;
  64796. /**
  64797. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64798. */
  64799. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64800. /**
  64801. * Gets a boolean indicating that the content is loaded
  64802. */
  64803. readonly isLoaded: boolean;
  64804. /**
  64805. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64806. */
  64807. populateNinePatchSlicesFromImage: boolean;
  64808. /**
  64809. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64810. * Beware using this as this will comsume more memory as the image has to be stored twice
  64811. */
  64812. detectPointerOnOpaqueOnly: boolean;
  64813. /**
  64814. * Gets or sets the left value for slicing (9-patch)
  64815. */
  64816. sliceLeft: number;
  64817. /**
  64818. * Gets or sets the right value for slicing (9-patch)
  64819. */
  64820. sliceRight: number;
  64821. /**
  64822. * Gets or sets the top value for slicing (9-patch)
  64823. */
  64824. sliceTop: number;
  64825. /**
  64826. * Gets or sets the bottom value for slicing (9-patch)
  64827. */
  64828. sliceBottom: number;
  64829. /**
  64830. * Gets or sets the left coordinate in the source image
  64831. */
  64832. sourceLeft: number;
  64833. /**
  64834. * Gets or sets the top coordinate in the source image
  64835. */
  64836. sourceTop: number;
  64837. /**
  64838. * Gets or sets the width to capture in the source image
  64839. */
  64840. sourceWidth: number;
  64841. /**
  64842. * Gets or sets the height to capture in the source image
  64843. */
  64844. sourceHeight: number;
  64845. /**
  64846. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64847. * @see http://doc.babylonjs.com/how_to/gui#image
  64848. */
  64849. autoScale: boolean;
  64850. /** Gets or sets the streching mode used by the image */
  64851. stretch: number;
  64852. /**
  64853. * Gets or sets the internal DOM image used to render the control
  64854. */
  64855. domImage: HTMLImageElement;
  64856. private _onImageLoaded;
  64857. private _extractNinePatchSliceDataFromImage;
  64858. /**
  64859. * Gets or sets image source url
  64860. */
  64861. source: BABYLON.Nullable<string>;
  64862. /**
  64863. * Checks for svg document with icon id present
  64864. */
  64865. private _svgCheck;
  64866. /**
  64867. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64868. * given external svg file and icon id
  64869. */
  64870. private _getSVGAttribs;
  64871. /**
  64872. * Gets or sets the cell width to use when animation sheet is enabled
  64873. * @see http://doc.babylonjs.com/how_to/gui#image
  64874. */
  64875. cellWidth: number;
  64876. /**
  64877. * Gets or sets the cell height to use when animation sheet is enabled
  64878. * @see http://doc.babylonjs.com/how_to/gui#image
  64879. */
  64880. cellHeight: number;
  64881. /**
  64882. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64883. * @see http://doc.babylonjs.com/how_to/gui#image
  64884. */
  64885. cellId: number;
  64886. /**
  64887. * Creates a new Image
  64888. * @param name defines the control name
  64889. * @param url defines the image url
  64890. */
  64891. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64892. /**
  64893. * Tests if a given coordinates belong to the current control
  64894. * @param x defines x coordinate to test
  64895. * @param y defines y coordinate to test
  64896. * @returns true if the coordinates are inside the control
  64897. */
  64898. contains(x: number, y: number): boolean;
  64899. protected _getTypeName(): string;
  64900. /** Force the control to synchronize with its content */
  64901. synchronizeSizeWithContent(): void;
  64902. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64903. private _prepareWorkingCanvasForOpaqueDetection;
  64904. private _drawImage;
  64905. _draw(context: CanvasRenderingContext2D): void;
  64906. private _renderCornerPatch;
  64907. private _renderNinePatch;
  64908. dispose(): void;
  64909. /** STRETCH_NONE */
  64910. static readonly STRETCH_NONE: number;
  64911. /** STRETCH_FILL */
  64912. static readonly STRETCH_FILL: number;
  64913. /** STRETCH_UNIFORM */
  64914. static readonly STRETCH_UNIFORM: number;
  64915. /** STRETCH_EXTEND */
  64916. static readonly STRETCH_EXTEND: number;
  64917. /** NINE_PATCH */
  64918. static readonly STRETCH_NINE_PATCH: number;
  64919. }
  64920. }
  64921. declare module BABYLON.GUI {
  64922. /**
  64923. * Class used to create 2D buttons
  64924. */
  64925. export class Button extends Rectangle {
  64926. name?: string | undefined;
  64927. /**
  64928. * Function called to generate a pointer enter animation
  64929. */
  64930. pointerEnterAnimation: () => void;
  64931. /**
  64932. * Function called to generate a pointer out animation
  64933. */
  64934. pointerOutAnimation: () => void;
  64935. /**
  64936. * Function called to generate a pointer down animation
  64937. */
  64938. pointerDownAnimation: () => void;
  64939. /**
  64940. * Function called to generate a pointer up animation
  64941. */
  64942. pointerUpAnimation: () => void;
  64943. /**
  64944. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64945. */
  64946. delegatePickingToChildren: boolean;
  64947. private _image;
  64948. /**
  64949. * Returns the image part of the button (if any)
  64950. */
  64951. readonly image: BABYLON.Nullable<Image>;
  64952. private _textBlock;
  64953. /**
  64954. * Returns the image part of the button (if any)
  64955. */
  64956. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64957. /**
  64958. * Creates a new Button
  64959. * @param name defines the name of the button
  64960. */
  64961. constructor(name?: string | undefined);
  64962. protected _getTypeName(): string;
  64963. /** @hidden */
  64964. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64965. /** @hidden */
  64966. _onPointerEnter(target: Control): boolean;
  64967. /** @hidden */
  64968. _onPointerOut(target: Control, force?: boolean): void;
  64969. /** @hidden */
  64970. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64971. /** @hidden */
  64972. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64973. /**
  64974. * Creates a new button made with an image and a text
  64975. * @param name defines the name of the button
  64976. * @param text defines the text of the button
  64977. * @param imageUrl defines the url of the image
  64978. * @returns a new Button
  64979. */
  64980. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64981. /**
  64982. * Creates a new button made with an image
  64983. * @param name defines the name of the button
  64984. * @param imageUrl defines the url of the image
  64985. * @returns a new Button
  64986. */
  64987. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64988. /**
  64989. * Creates a new button made with a text
  64990. * @param name defines the name of the button
  64991. * @param text defines the text of the button
  64992. * @returns a new Button
  64993. */
  64994. static CreateSimpleButton(name: string, text: string): Button;
  64995. /**
  64996. * Creates a new button made with an image and a centered text
  64997. * @param name defines the name of the button
  64998. * @param text defines the text of the button
  64999. * @param imageUrl defines the url of the image
  65000. * @returns a new Button
  65001. */
  65002. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  65003. }
  65004. }
  65005. declare module BABYLON.GUI {
  65006. /**
  65007. * Class used to create a 2D stack panel container
  65008. */
  65009. export class StackPanel extends Container {
  65010. name?: string | undefined;
  65011. private _isVertical;
  65012. private _manualWidth;
  65013. private _manualHeight;
  65014. private _doNotTrackManualChanges;
  65015. /**
  65016. * Gets or sets a boolean indicating that layou warnings should be ignored
  65017. */
  65018. ignoreLayoutWarnings: boolean;
  65019. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  65020. isVertical: boolean;
  65021. /**
  65022. * Gets or sets panel width.
  65023. * This value should not be set when in horizontal mode as it will be computed automatically
  65024. */
  65025. width: string | number;
  65026. /**
  65027. * Gets or sets panel height.
  65028. * This value should not be set when in vertical mode as it will be computed automatically
  65029. */
  65030. height: string | number;
  65031. /**
  65032. * Creates a new StackPanel
  65033. * @param name defines control name
  65034. */
  65035. constructor(name?: string | undefined);
  65036. protected _getTypeName(): string;
  65037. /** @hidden */
  65038. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65039. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65040. protected _postMeasure(): void;
  65041. }
  65042. }
  65043. declare module BABYLON.GUI {
  65044. /**
  65045. * Class used to represent a 2D checkbox
  65046. */
  65047. export class Checkbox extends Control {
  65048. name?: string | undefined;
  65049. private _isChecked;
  65050. private _background;
  65051. private _checkSizeRatio;
  65052. private _thickness;
  65053. /** Gets or sets border thickness */
  65054. thickness: number;
  65055. /**
  65056. * BABYLON.Observable raised when isChecked property changes
  65057. */
  65058. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65059. /** Gets or sets a value indicating the ratio between overall size and check size */
  65060. checkSizeRatio: number;
  65061. /** Gets or sets background color */
  65062. background: string;
  65063. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65064. isChecked: boolean;
  65065. /**
  65066. * Creates a new CheckBox
  65067. * @param name defines the control name
  65068. */
  65069. constructor(name?: string | undefined);
  65070. protected _getTypeName(): string;
  65071. /** @hidden */
  65072. _draw(context: CanvasRenderingContext2D): void;
  65073. /** @hidden */
  65074. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65075. /**
  65076. * Utility function to easily create a checkbox with a header
  65077. * @param title defines the label to use for the header
  65078. * @param onValueChanged defines the callback to call when value changes
  65079. * @returns a StackPanel containing the checkbox and a textBlock
  65080. */
  65081. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  65082. }
  65083. }
  65084. declare module BABYLON.GUI {
  65085. /**
  65086. * Class used to store key control properties
  65087. */
  65088. export class KeyPropertySet {
  65089. /** Width */
  65090. width?: string;
  65091. /** Height */
  65092. height?: string;
  65093. /** Left padding */
  65094. paddingLeft?: string;
  65095. /** Right padding */
  65096. paddingRight?: string;
  65097. /** Top padding */
  65098. paddingTop?: string;
  65099. /** Bottom padding */
  65100. paddingBottom?: string;
  65101. /** Foreground color */
  65102. color?: string;
  65103. /** Background color */
  65104. background?: string;
  65105. }
  65106. /**
  65107. * Class used to create virtual keyboard
  65108. */
  65109. export class VirtualKeyboard extends StackPanel {
  65110. /** BABYLON.Observable raised when a key is pressed */
  65111. onKeyPressObservable: BABYLON.Observable<string>;
  65112. /** Gets or sets default key button width */
  65113. defaultButtonWidth: string;
  65114. /** Gets or sets default key button height */
  65115. defaultButtonHeight: string;
  65116. /** Gets or sets default key button left padding */
  65117. defaultButtonPaddingLeft: string;
  65118. /** Gets or sets default key button right padding */
  65119. defaultButtonPaddingRight: string;
  65120. /** Gets or sets default key button top padding */
  65121. defaultButtonPaddingTop: string;
  65122. /** Gets or sets default key button bottom padding */
  65123. defaultButtonPaddingBottom: string;
  65124. /** Gets or sets default key button foreground color */
  65125. defaultButtonColor: string;
  65126. /** Gets or sets default key button background color */
  65127. defaultButtonBackground: string;
  65128. /** Gets or sets shift button foreground color */
  65129. shiftButtonColor: string;
  65130. /** Gets or sets shift button thickness*/
  65131. selectedShiftThickness: number;
  65132. /** Gets shift key state */
  65133. shiftState: number;
  65134. protected _getTypeName(): string;
  65135. private _createKey;
  65136. /**
  65137. * Adds a new row of keys
  65138. * @param keys defines the list of keys to add
  65139. * @param propertySets defines the associated property sets
  65140. */
  65141. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  65142. /**
  65143. * Set the shift key to a specific state
  65144. * @param shiftState defines the new shift state
  65145. */
  65146. applyShiftState(shiftState: number): void;
  65147. private _currentlyConnectedInputText;
  65148. private _connectedInputTexts;
  65149. private _onKeyPressObserver;
  65150. /** Gets the input text control currently attached to the keyboard */
  65151. readonly connectedInputText: BABYLON.Nullable<InputText>;
  65152. /**
  65153. * Connects the keyboard with an input text control
  65154. *
  65155. * @param input defines the target control
  65156. */
  65157. connect(input: InputText): void;
  65158. /**
  65159. * Disconnects the keyboard from connected InputText controls
  65160. *
  65161. * @param input optionally defines a target control, otherwise all are disconnected
  65162. */
  65163. disconnect(input?: InputText): void;
  65164. private _removeConnectedInputObservables;
  65165. /**
  65166. * Release all resources
  65167. */
  65168. dispose(): void;
  65169. /**
  65170. * Creates a new keyboard using a default layout
  65171. *
  65172. * @param name defines control name
  65173. * @returns a new VirtualKeyboard
  65174. */
  65175. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  65176. }
  65177. }
  65178. declare module BABYLON.GUI {
  65179. /**
  65180. * Class used to create input text control
  65181. */
  65182. export class InputText extends Control implements IFocusableControl {
  65183. name?: string | undefined;
  65184. private _text;
  65185. private _placeholderText;
  65186. private _background;
  65187. private _focusedBackground;
  65188. private _focusedColor;
  65189. private _placeholderColor;
  65190. private _thickness;
  65191. private _margin;
  65192. private _autoStretchWidth;
  65193. private _maxWidth;
  65194. private _isFocused;
  65195. private _blinkTimeout;
  65196. private _blinkIsEven;
  65197. private _cursorOffset;
  65198. private _scrollLeft;
  65199. private _textWidth;
  65200. private _clickedCoordinate;
  65201. private _deadKey;
  65202. private _addKey;
  65203. private _currentKey;
  65204. private _isTextHighlightOn;
  65205. private _textHighlightColor;
  65206. private _highligherOpacity;
  65207. private _highlightedText;
  65208. private _startHighlightIndex;
  65209. private _endHighlightIndex;
  65210. private _cursorIndex;
  65211. private _onFocusSelectAll;
  65212. private _isPointerDown;
  65213. private _onClipboardObserver;
  65214. private _onPointerDblTapObserver;
  65215. /** @hidden */
  65216. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  65217. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  65218. promptMessage: string;
  65219. /** Force disable prompt on mobile device */
  65220. disableMobilePrompt: boolean;
  65221. /** BABYLON.Observable raised when the text changes */
  65222. onTextChangedObservable: BABYLON.Observable<InputText>;
  65223. /** BABYLON.Observable raised just before an entered character is to be added */
  65224. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  65225. /** BABYLON.Observable raised when the control gets the focus */
  65226. onFocusObservable: BABYLON.Observable<InputText>;
  65227. /** BABYLON.Observable raised when the control loses the focus */
  65228. onBlurObservable: BABYLON.Observable<InputText>;
  65229. /**Observable raised when the text is highlighted */
  65230. onTextHighlightObservable: BABYLON.Observable<InputText>;
  65231. /**Observable raised when copy event is triggered */
  65232. onTextCopyObservable: BABYLON.Observable<InputText>;
  65233. /** BABYLON.Observable raised when cut event is triggered */
  65234. onTextCutObservable: BABYLON.Observable<InputText>;
  65235. /** BABYLON.Observable raised when paste event is triggered */
  65236. onTextPasteObservable: BABYLON.Observable<InputText>;
  65237. /** BABYLON.Observable raised when a key event was processed */
  65238. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  65239. /** Gets or sets the maximum width allowed by the control */
  65240. maxWidth: string | number;
  65241. /** Gets the maximum width allowed by the control in pixels */
  65242. readonly maxWidthInPixels: number;
  65243. /** Gets or sets the text highlighter transparency; default: 0.4 */
  65244. highligherOpacity: number;
  65245. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  65246. onFocusSelectAll: boolean;
  65247. /** Gets or sets the text hightlight color */
  65248. textHighlightColor: string;
  65249. /** Gets or sets control margin */
  65250. margin: string;
  65251. /** Gets control margin in pixels */
  65252. readonly marginInPixels: number;
  65253. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  65254. autoStretchWidth: boolean;
  65255. /** Gets or sets border thickness */
  65256. thickness: number;
  65257. /** Gets or sets the background color when focused */
  65258. focusedBackground: string;
  65259. /** Gets or sets the background color when focused */
  65260. focusedColor: string;
  65261. /** Gets or sets the background color */
  65262. background: string;
  65263. /** Gets or sets the placeholder color */
  65264. placeholderColor: string;
  65265. /** Gets or sets the text displayed when the control is empty */
  65266. placeholderText: string;
  65267. /** Gets or sets the dead key flag */
  65268. deadKey: boolean;
  65269. /** Gets or sets the highlight text */
  65270. highlightedText: string;
  65271. /** Gets or sets if the current key should be added */
  65272. addKey: boolean;
  65273. /** Gets or sets the value of the current key being entered */
  65274. currentKey: string;
  65275. /** Gets or sets the text displayed in the control */
  65276. text: string;
  65277. /** Gets or sets control width */
  65278. width: string | number;
  65279. /**
  65280. * Creates a new InputText
  65281. * @param name defines the control name
  65282. * @param text defines the text of the control
  65283. */
  65284. constructor(name?: string | undefined, text?: string);
  65285. /** @hidden */
  65286. onBlur(): void;
  65287. /** @hidden */
  65288. onFocus(): void;
  65289. protected _getTypeName(): string;
  65290. /**
  65291. * Function called to get the list of controls that should not steal the focus from this control
  65292. * @returns an array of controls
  65293. */
  65294. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  65295. /** @hidden */
  65296. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  65297. /** @hidden */
  65298. private _updateValueFromCursorIndex;
  65299. /** @hidden */
  65300. private _processDblClick;
  65301. /** @hidden */
  65302. private _selectAllText;
  65303. /**
  65304. * Handles the keyboard event
  65305. * @param evt Defines the KeyboardEvent
  65306. */
  65307. processKeyboard(evt: KeyboardEvent): void;
  65308. /** @hidden */
  65309. private _onCopyText;
  65310. /** @hidden */
  65311. private _onCutText;
  65312. /** @hidden */
  65313. private _onPasteText;
  65314. _draw(context: CanvasRenderingContext2D): void;
  65315. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65316. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65317. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65318. protected _beforeRenderText(text: string): string;
  65319. dispose(): void;
  65320. }
  65321. }
  65322. declare module BABYLON.GUI {
  65323. /**
  65324. * Class used to create a 2D grid container
  65325. */
  65326. export class Grid extends Container {
  65327. name?: string | undefined;
  65328. private _rowDefinitions;
  65329. private _columnDefinitions;
  65330. private _cells;
  65331. private _childControls;
  65332. /**
  65333. * Gets the number of columns
  65334. */
  65335. readonly columnCount: number;
  65336. /**
  65337. * Gets the number of rows
  65338. */
  65339. readonly rowCount: number;
  65340. /** Gets the list of children */
  65341. readonly children: Control[];
  65342. /** Gets the list of cells (e.g. the containers) */
  65343. readonly cells: {
  65344. [key: string]: Container;
  65345. };
  65346. /**
  65347. * Gets the definition of a specific row
  65348. * @param index defines the index of the row
  65349. * @returns the row definition
  65350. */
  65351. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65352. /**
  65353. * Gets the definition of a specific column
  65354. * @param index defines the index of the column
  65355. * @returns the column definition
  65356. */
  65357. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  65358. /**
  65359. * Adds a new row to the grid
  65360. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65361. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  65362. * @returns the current grid
  65363. */
  65364. addRowDefinition(height: number, isPixel?: boolean): Grid;
  65365. /**
  65366. * Adds a new column to the grid
  65367. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65368. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65369. * @returns the current grid
  65370. */
  65371. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  65372. /**
  65373. * Update a row definition
  65374. * @param index defines the index of the row to update
  65375. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  65376. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  65377. * @returns the current grid
  65378. */
  65379. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  65380. /**
  65381. * Update a column definition
  65382. * @param index defines the index of the column to update
  65383. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  65384. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  65385. * @returns the current grid
  65386. */
  65387. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  65388. /**
  65389. * Gets the list of children stored in a specific cell
  65390. * @param row defines the row to check
  65391. * @param column defines the column to check
  65392. * @returns the list of controls
  65393. */
  65394. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  65395. /**
  65396. * Gets a string representing the child cell info (row x column)
  65397. * @param child defines the control to get info from
  65398. * @returns a string containing the child cell info (row x column)
  65399. */
  65400. getChildCellInfo(child: Control): string;
  65401. private _removeCell;
  65402. private _offsetCell;
  65403. /**
  65404. * Remove a column definition at specified index
  65405. * @param index defines the index of the column to remove
  65406. * @returns the current grid
  65407. */
  65408. removeColumnDefinition(index: number): Grid;
  65409. /**
  65410. * Remove a row definition at specified index
  65411. * @param index defines the index of the row to remove
  65412. * @returns the current grid
  65413. */
  65414. removeRowDefinition(index: number): Grid;
  65415. /**
  65416. * Adds a new control to the current grid
  65417. * @param control defines the control to add
  65418. * @param row defines the row where to add the control (0 by default)
  65419. * @param column defines the column where to add the control (0 by default)
  65420. * @returns the current grid
  65421. */
  65422. addControl(control: Control, row?: number, column?: number): Grid;
  65423. /**
  65424. * Removes a control from the current container
  65425. * @param control defines the control to remove
  65426. * @returns the current container
  65427. */
  65428. removeControl(control: Control): Container;
  65429. /**
  65430. * Creates a new Grid
  65431. * @param name defines control name
  65432. */
  65433. constructor(name?: string | undefined);
  65434. protected _getTypeName(): string;
  65435. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  65436. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65437. _flagDescendantsAsMatrixDirty(): void;
  65438. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65439. /** Releases associated resources */
  65440. dispose(): void;
  65441. }
  65442. }
  65443. declare module BABYLON.GUI {
  65444. /** Class used to create color pickers */
  65445. export class ColorPicker extends Control {
  65446. name?: string | undefined;
  65447. private static _Epsilon;
  65448. private _colorWheelCanvas;
  65449. private _value;
  65450. private _tmpColor;
  65451. private _pointerStartedOnSquare;
  65452. private _pointerStartedOnWheel;
  65453. private _squareLeft;
  65454. private _squareTop;
  65455. private _squareSize;
  65456. private _h;
  65457. private _s;
  65458. private _v;
  65459. private _lastPointerDownID;
  65460. /**
  65461. * BABYLON.Observable raised when the value changes
  65462. */
  65463. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  65464. /** Gets or sets the color of the color picker */
  65465. value: BABYLON.Color3;
  65466. /**
  65467. * Gets or sets control width
  65468. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65469. */
  65470. width: string | number;
  65471. /**
  65472. * Gets or sets control height
  65473. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  65474. */
  65475. /** Gets or sets control height */
  65476. height: string | number;
  65477. /** Gets or sets control size */
  65478. size: string | number;
  65479. /**
  65480. * Creates a new ColorPicker
  65481. * @param name defines the control name
  65482. */
  65483. constructor(name?: string | undefined);
  65484. protected _getTypeName(): string;
  65485. /** @hidden */
  65486. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65487. private _updateSquareProps;
  65488. private _drawGradientSquare;
  65489. private _drawCircle;
  65490. private _createColorWheelCanvas;
  65491. /** @hidden */
  65492. _draw(context: CanvasRenderingContext2D): void;
  65493. private _pointerIsDown;
  65494. private _updateValueFromPointer;
  65495. private _isPointOnSquare;
  65496. private _isPointOnWheel;
  65497. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65498. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65499. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65500. /**
  65501. * This function expands the color picker by creating a color picker dialog with manual
  65502. * color value input and the ability to save colors into an array to be used later in
  65503. * subsequent launches of the dialogue.
  65504. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  65505. * @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.
  65506. * @returns picked color as a hex string and the saved colors array as hex strings.
  65507. */
  65508. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  65509. pickerWidth?: string;
  65510. pickerHeight?: string;
  65511. headerHeight?: string;
  65512. lastColor?: string;
  65513. swatchLimit?: number;
  65514. numSwatchesPerLine?: number;
  65515. savedColors?: Array<string>;
  65516. }): Promise<{
  65517. savedColors?: string[];
  65518. pickedColor: string;
  65519. }>;
  65520. }
  65521. }
  65522. declare module BABYLON.GUI {
  65523. /** Class used to create 2D ellipse containers */
  65524. export class Ellipse extends Container {
  65525. name?: string | undefined;
  65526. private _thickness;
  65527. /** Gets or sets border thickness */
  65528. thickness: number;
  65529. /**
  65530. * Creates a new Ellipse
  65531. * @param name defines the control name
  65532. */
  65533. constructor(name?: string | undefined);
  65534. protected _getTypeName(): string;
  65535. protected _localDraw(context: CanvasRenderingContext2D): void;
  65536. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65537. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  65538. }
  65539. }
  65540. declare module BABYLON.GUI {
  65541. /**
  65542. * Class used to create a password control
  65543. */
  65544. export class InputPassword extends InputText {
  65545. protected _beforeRenderText(text: string): string;
  65546. }
  65547. }
  65548. declare module BABYLON.GUI {
  65549. /** Class used to render 2D lines */
  65550. export class Line extends Control {
  65551. name?: string | undefined;
  65552. private _lineWidth;
  65553. private _x1;
  65554. private _y1;
  65555. private _x2;
  65556. private _y2;
  65557. private _dash;
  65558. private _connectedControl;
  65559. private _connectedControlDirtyObserver;
  65560. /** Gets or sets the dash pattern */
  65561. dash: Array<number>;
  65562. /** Gets or sets the control connected with the line end */
  65563. connectedControl: Control;
  65564. /** Gets or sets start coordinates on X axis */
  65565. x1: string | number;
  65566. /** Gets or sets start coordinates on Y axis */
  65567. y1: string | number;
  65568. /** Gets or sets end coordinates on X axis */
  65569. x2: string | number;
  65570. /** Gets or sets end coordinates on Y axis */
  65571. y2: string | number;
  65572. /** Gets or sets line width */
  65573. lineWidth: number;
  65574. /** Gets or sets horizontal alignment */
  65575. horizontalAlignment: number;
  65576. /** Gets or sets vertical alignment */
  65577. verticalAlignment: number;
  65578. private readonly _effectiveX2;
  65579. private readonly _effectiveY2;
  65580. /**
  65581. * Creates a new Line
  65582. * @param name defines the control name
  65583. */
  65584. constructor(name?: string | undefined);
  65585. protected _getTypeName(): string;
  65586. _draw(context: CanvasRenderingContext2D): void;
  65587. _measure(): void;
  65588. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65589. /**
  65590. * Move one end of the line given 3D cartesian coordinates.
  65591. * @param position Targeted world position
  65592. * @param scene BABYLON.Scene
  65593. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65594. */
  65595. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65596. /**
  65597. * Move one end of the line to a position in screen absolute space.
  65598. * @param projectedPosition Position in screen absolute space (X, Y)
  65599. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65600. */
  65601. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65602. }
  65603. }
  65604. declare module BABYLON.GUI {
  65605. /**
  65606. * Class used to store a point for a MultiLine object.
  65607. * The point can be pure 2D coordinates, a mesh or a control
  65608. */
  65609. export class MultiLinePoint {
  65610. private _multiLine;
  65611. private _x;
  65612. private _y;
  65613. private _control;
  65614. private _mesh;
  65615. private _controlObserver;
  65616. private _meshObserver;
  65617. /** @hidden */
  65618. _point: BABYLON.Vector2;
  65619. /**
  65620. * Creates a new MultiLinePoint
  65621. * @param multiLine defines the source MultiLine object
  65622. */
  65623. constructor(multiLine: MultiLine);
  65624. /** Gets or sets x coordinate */
  65625. x: string | number;
  65626. /** Gets or sets y coordinate */
  65627. y: string | number;
  65628. /** Gets or sets the control associated with this point */
  65629. control: BABYLON.Nullable<Control>;
  65630. /** Gets or sets the mesh associated with this point */
  65631. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65632. /** Resets links */
  65633. resetLinks(): void;
  65634. /**
  65635. * Gets a translation vector
  65636. * @returns the translation vector
  65637. */
  65638. translate(): BABYLON.Vector2;
  65639. private _translatePoint;
  65640. /** Release associated resources */
  65641. dispose(): void;
  65642. }
  65643. }
  65644. declare module BABYLON.GUI {
  65645. /**
  65646. * Class used to create multi line control
  65647. */
  65648. export class MultiLine extends Control {
  65649. name?: string | undefined;
  65650. private _lineWidth;
  65651. private _dash;
  65652. private _points;
  65653. private _minX;
  65654. private _minY;
  65655. private _maxX;
  65656. private _maxY;
  65657. /**
  65658. * Creates a new MultiLine
  65659. * @param name defines the control name
  65660. */
  65661. constructor(name?: string | undefined);
  65662. /** Gets or sets dash pattern */
  65663. dash: Array<number>;
  65664. /**
  65665. * Gets point stored at specified index
  65666. * @param index defines the index to look for
  65667. * @returns the requested point if found
  65668. */
  65669. getAt(index: number): MultiLinePoint;
  65670. /** Function called when a point is updated */
  65671. onPointUpdate: () => void;
  65672. /**
  65673. * Adds new points to the point collection
  65674. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65675. * @returns the list of created MultiLinePoint
  65676. */
  65677. add(...items: (AbstractMesh | Control | {
  65678. x: string | number;
  65679. y: string | number;
  65680. })[]): MultiLinePoint[];
  65681. /**
  65682. * Adds a new point to the point collection
  65683. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65684. * @returns the created MultiLinePoint
  65685. */
  65686. push(item?: (AbstractMesh | Control | {
  65687. x: string | number;
  65688. y: string | number;
  65689. })): MultiLinePoint;
  65690. /**
  65691. * Remove a specific value or point from the active point collection
  65692. * @param value defines the value or point to remove
  65693. */
  65694. remove(value: number | MultiLinePoint): void;
  65695. /**
  65696. * Resets this object to initial state (no point)
  65697. */
  65698. reset(): void;
  65699. /**
  65700. * Resets all links
  65701. */
  65702. resetLinks(): void;
  65703. /** Gets or sets line width */
  65704. lineWidth: number;
  65705. horizontalAlignment: number;
  65706. verticalAlignment: number;
  65707. protected _getTypeName(): string;
  65708. _draw(context: CanvasRenderingContext2D): void;
  65709. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65710. _measure(): void;
  65711. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65712. dispose(): void;
  65713. }
  65714. }
  65715. declare module BABYLON.GUI {
  65716. /**
  65717. * Class used to create radio button controls
  65718. */
  65719. export class RadioButton extends Control {
  65720. name?: string | undefined;
  65721. private _isChecked;
  65722. private _background;
  65723. private _checkSizeRatio;
  65724. private _thickness;
  65725. /** Gets or sets border thickness */
  65726. thickness: number;
  65727. /** Gets or sets group name */
  65728. group: string;
  65729. /** BABYLON.Observable raised when isChecked is changed */
  65730. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65731. /** Gets or sets a value indicating the ratio between overall size and check size */
  65732. checkSizeRatio: number;
  65733. /** Gets or sets background color */
  65734. background: string;
  65735. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65736. isChecked: boolean;
  65737. /**
  65738. * Creates a new RadioButton
  65739. * @param name defines the control name
  65740. */
  65741. constructor(name?: string | undefined);
  65742. protected _getTypeName(): string;
  65743. _draw(context: CanvasRenderingContext2D): void;
  65744. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65745. /**
  65746. * Utility function to easily create a radio button with a header
  65747. * @param title defines the label to use for the header
  65748. * @param group defines the group to use for the radio button
  65749. * @param isChecked defines the initial state of the radio button
  65750. * @param onValueChanged defines the callback to call when value changes
  65751. * @returns a StackPanel containing the radio button and a textBlock
  65752. */
  65753. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65754. }
  65755. }
  65756. declare module BABYLON.GUI {
  65757. /**
  65758. * Class used to create slider controls
  65759. */
  65760. export class BaseSlider extends Control {
  65761. name?: string | undefined;
  65762. protected _thumbWidth: ValueAndUnit;
  65763. private _minimum;
  65764. private _maximum;
  65765. private _value;
  65766. private _isVertical;
  65767. protected _barOffset: ValueAndUnit;
  65768. private _isThumbClamped;
  65769. protected _displayThumb: boolean;
  65770. private _step;
  65771. private _lastPointerDownID;
  65772. protected _effectiveBarOffset: number;
  65773. protected _renderLeft: number;
  65774. protected _renderTop: number;
  65775. protected _renderWidth: number;
  65776. protected _renderHeight: number;
  65777. protected _backgroundBoxLength: number;
  65778. protected _backgroundBoxThickness: number;
  65779. protected _effectiveThumbThickness: number;
  65780. /** BABYLON.Observable raised when the sldier value changes */
  65781. onValueChangedObservable: BABYLON.Observable<number>;
  65782. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65783. displayThumb: boolean;
  65784. /** Gets or sets a step to apply to values (0 by default) */
  65785. step: number;
  65786. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65787. barOffset: string | number;
  65788. /** Gets main bar offset in pixels*/
  65789. readonly barOffsetInPixels: number;
  65790. /** Gets or sets thumb width */
  65791. thumbWidth: string | number;
  65792. /** Gets thumb width in pixels */
  65793. readonly thumbWidthInPixels: number;
  65794. /** Gets or sets minimum value */
  65795. minimum: number;
  65796. /** Gets or sets maximum value */
  65797. maximum: number;
  65798. /** Gets or sets current value */
  65799. value: number;
  65800. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65801. isVertical: boolean;
  65802. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65803. isThumbClamped: boolean;
  65804. /**
  65805. * Creates a new BaseSlider
  65806. * @param name defines the control name
  65807. */
  65808. constructor(name?: string | undefined);
  65809. protected _getTypeName(): string;
  65810. protected _getThumbPosition(): number;
  65811. protected _getThumbThickness(type: string): number;
  65812. protected _prepareRenderingData(type: string): void;
  65813. private _pointerIsDown;
  65814. /** @hidden */
  65815. protected _updateValueFromPointer(x: number, y: number): void;
  65816. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65817. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  65818. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65819. }
  65820. }
  65821. declare module BABYLON.GUI {
  65822. /**
  65823. * Class used to create slider controls
  65824. */
  65825. export class Slider extends BaseSlider {
  65826. name?: string | undefined;
  65827. private _background;
  65828. private _borderColor;
  65829. private _isThumbCircle;
  65830. protected _displayValueBar: boolean;
  65831. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65832. displayValueBar: boolean;
  65833. /** Gets or sets border color */
  65834. borderColor: string;
  65835. /** Gets or sets background color */
  65836. background: string;
  65837. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65838. isThumbCircle: boolean;
  65839. /**
  65840. * Creates a new Slider
  65841. * @param name defines the control name
  65842. */
  65843. constructor(name?: string | undefined);
  65844. protected _getTypeName(): string;
  65845. _draw(context: CanvasRenderingContext2D): void;
  65846. }
  65847. }
  65848. declare module BABYLON.GUI {
  65849. /** Class used to create a RadioGroup
  65850. * which contains groups of radio buttons
  65851. */
  65852. export class SelectorGroup {
  65853. /** name of SelectorGroup */
  65854. name: string;
  65855. private _groupPanel;
  65856. private _selectors;
  65857. private _groupHeader;
  65858. /**
  65859. * Creates a new SelectorGroup
  65860. * @param name of group, used as a group heading
  65861. */
  65862. constructor(
  65863. /** name of SelectorGroup */
  65864. name: string);
  65865. /** Gets the groupPanel of the SelectorGroup */
  65866. readonly groupPanel: StackPanel;
  65867. /** Gets the selectors array */
  65868. readonly selectors: StackPanel[];
  65869. /** Gets and sets the group header */
  65870. header: string;
  65871. /** @hidden */
  65872. private _addGroupHeader;
  65873. /** @hidden*/
  65874. _getSelector(selectorNb: number): StackPanel | undefined;
  65875. /** Removes the selector at the given position
  65876. * @param selectorNb the position of the selector within the group
  65877. */
  65878. removeSelector(selectorNb: number): void;
  65879. }
  65880. /** Class used to create a CheckboxGroup
  65881. * which contains groups of checkbox buttons
  65882. */
  65883. export class CheckboxGroup extends SelectorGroup {
  65884. /** Adds a checkbox as a control
  65885. * @param text is the label for the selector
  65886. * @param func is the function called when the Selector is checked
  65887. * @param checked is true when Selector is checked
  65888. */
  65889. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65890. /** @hidden */
  65891. _setSelectorLabel(selectorNb: number, label: string): void;
  65892. /** @hidden */
  65893. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65894. /** @hidden */
  65895. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65896. /** @hidden */
  65897. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65898. }
  65899. /** Class used to create a RadioGroup
  65900. * which contains groups of radio buttons
  65901. */
  65902. export class RadioGroup extends SelectorGroup {
  65903. private _selectNb;
  65904. /** Adds a radio button as a control
  65905. * @param label is the label for the selector
  65906. * @param func is the function called when the Selector is checked
  65907. * @param checked is true when Selector is checked
  65908. */
  65909. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65910. /** @hidden */
  65911. _setSelectorLabel(selectorNb: number, label: string): void;
  65912. /** @hidden */
  65913. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65914. /** @hidden */
  65915. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65916. /** @hidden */
  65917. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65918. }
  65919. /** Class used to create a SliderGroup
  65920. * which contains groups of slider buttons
  65921. */
  65922. export class SliderGroup extends SelectorGroup {
  65923. /**
  65924. * Adds a slider to the SelectorGroup
  65925. * @param label is the label for the SliderBar
  65926. * @param func is the function called when the Slider moves
  65927. * @param unit is a string describing the units used, eg degrees or metres
  65928. * @param min is the minimum value for the Slider
  65929. * @param max is the maximum value for the Slider
  65930. * @param value is the start value for the Slider between min and max
  65931. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65932. */
  65933. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65934. /** @hidden */
  65935. _setSelectorLabel(selectorNb: number, label: string): void;
  65936. /** @hidden */
  65937. _setSelectorLabelColor(selectorNb: number, color: string): void;
  65938. /** @hidden */
  65939. _setSelectorButtonColor(selectorNb: number, color: string): void;
  65940. /** @hidden */
  65941. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65942. }
  65943. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65944. * @see http://doc.babylonjs.com/how_to/selector
  65945. */
  65946. export class SelectionPanel extends Rectangle {
  65947. /** name of SelectionPanel */
  65948. name: string;
  65949. /** an array of SelectionGroups */
  65950. groups: SelectorGroup[];
  65951. private _panel;
  65952. private _buttonColor;
  65953. private _buttonBackground;
  65954. private _headerColor;
  65955. private _barColor;
  65956. private _barHeight;
  65957. private _spacerHeight;
  65958. private _labelColor;
  65959. private _groups;
  65960. private _bars;
  65961. /**
  65962. * Creates a new SelectionPanel
  65963. * @param name of SelectionPanel
  65964. * @param groups is an array of SelectionGroups
  65965. */
  65966. constructor(
  65967. /** name of SelectionPanel */
  65968. name: string,
  65969. /** an array of SelectionGroups */
  65970. groups?: SelectorGroup[]);
  65971. protected _getTypeName(): string;
  65972. /** Gets or sets the headerColor */
  65973. headerColor: string;
  65974. private _setHeaderColor;
  65975. /** Gets or sets the button color */
  65976. buttonColor: string;
  65977. private _setbuttonColor;
  65978. /** Gets or sets the label color */
  65979. labelColor: string;
  65980. private _setLabelColor;
  65981. /** Gets or sets the button background */
  65982. buttonBackground: string;
  65983. private _setButtonBackground;
  65984. /** Gets or sets the color of separator bar */
  65985. barColor: string;
  65986. private _setBarColor;
  65987. /** Gets or sets the height of separator bar */
  65988. barHeight: string;
  65989. private _setBarHeight;
  65990. /** Gets or sets the height of spacers*/
  65991. spacerHeight: string;
  65992. private _setSpacerHeight;
  65993. /** Adds a bar between groups */
  65994. private _addSpacer;
  65995. /** Add a group to the selection panel
  65996. * @param group is the selector group to add
  65997. */
  65998. addGroup(group: SelectorGroup): void;
  65999. /** Remove the group from the given position
  66000. * @param groupNb is the position of the group in the list
  66001. */
  66002. removeGroup(groupNb: number): void;
  66003. /** Change a group header label
  66004. * @param label is the new group header label
  66005. * @param groupNb is the number of the group to relabel
  66006. * */
  66007. setHeaderName(label: string, groupNb: number): void;
  66008. /** Change selector label to the one given
  66009. * @param label is the new selector label
  66010. * @param groupNb is the number of the groupcontaining the selector
  66011. * @param selectorNb is the number of the selector within a group to relabel
  66012. * */
  66013. relabel(label: string, groupNb: number, selectorNb: number): void;
  66014. /** For a given group position remove the selector at the given position
  66015. * @param groupNb is the number of the group to remove the selector from
  66016. * @param selectorNb is the number of the selector within the group
  66017. */
  66018. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  66019. /** For a given group position of correct type add a checkbox button
  66020. * @param groupNb is the number of the group to remove the selector from
  66021. * @param label is the label for the selector
  66022. * @param func is the function called when the Selector is checked
  66023. * @param checked is true when Selector is checked
  66024. */
  66025. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66026. /** For a given group position of correct type add a radio button
  66027. * @param groupNb is the number of the group to remove the selector from
  66028. * @param label is the label for the selector
  66029. * @param func is the function called when the Selector is checked
  66030. * @param checked is true when Selector is checked
  66031. */
  66032. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  66033. /**
  66034. * For a given slider group add a slider
  66035. * @param groupNb is the number of the group to add the slider to
  66036. * @param label is the label for the Slider
  66037. * @param func is the function called when the Slider moves
  66038. * @param unit is a string describing the units used, eg degrees or metres
  66039. * @param min is the minimum value for the Slider
  66040. * @param max is the maximum value for the Slider
  66041. * @param value is the start value for the Slider between min and max
  66042. * @param onVal is the function used to format the value displayed, eg radians to degrees
  66043. */
  66044. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  66045. }
  66046. }
  66047. declare module BABYLON.GUI {
  66048. /**
  66049. * Class used to hold a the container for ScrollViewer
  66050. * @hidden
  66051. */
  66052. export class _ScrollViewerWindow extends Container {
  66053. parentClientWidth: number;
  66054. parentClientHeight: number;
  66055. /**
  66056. * Creates a new ScrollViewerWindow
  66057. * @param name of ScrollViewerWindow
  66058. */
  66059. constructor(name?: string);
  66060. protected _getTypeName(): string;
  66061. /** @hidden */
  66062. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66063. protected _postMeasure(): void;
  66064. }
  66065. }
  66066. declare module BABYLON.GUI {
  66067. /**
  66068. * Class used to create slider controls
  66069. */
  66070. export class ScrollBar extends BaseSlider {
  66071. name?: string | undefined;
  66072. private _background;
  66073. private _borderColor;
  66074. private _thumbMeasure;
  66075. /** Gets or sets border color */
  66076. borderColor: string;
  66077. /** Gets or sets background color */
  66078. background: string;
  66079. /**
  66080. * Creates a new Slider
  66081. * @param name defines the control name
  66082. */
  66083. constructor(name?: string | undefined);
  66084. protected _getTypeName(): string;
  66085. protected _getThumbThickness(): number;
  66086. _draw(context: CanvasRenderingContext2D): void;
  66087. private _first;
  66088. private _originX;
  66089. private _originY;
  66090. /** @hidden */
  66091. protected _updateValueFromPointer(x: number, y: number): void;
  66092. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  66093. }
  66094. }
  66095. declare module BABYLON.GUI {
  66096. /**
  66097. * Class used to hold a viewer window and sliders in a grid
  66098. */
  66099. export class ScrollViewer extends Rectangle {
  66100. private _grid;
  66101. private _horizontalBarSpace;
  66102. private _verticalBarSpace;
  66103. private _dragSpace;
  66104. private _horizontalBar;
  66105. private _verticalBar;
  66106. private _barColor;
  66107. private _barBackground;
  66108. private _barSize;
  66109. private _endLeft;
  66110. private _endTop;
  66111. private _window;
  66112. private _pointerIsOver;
  66113. private _wheelPrecision;
  66114. private _onPointerObserver;
  66115. private _clientWidth;
  66116. private _clientHeight;
  66117. /**
  66118. * Gets the horizontal scrollbar
  66119. */
  66120. readonly horizontalBar: ScrollBar;
  66121. /**
  66122. * Gets the vertical scrollbar
  66123. */
  66124. readonly verticalBar: ScrollBar;
  66125. /**
  66126. * Adds a new control to the current container
  66127. * @param control defines the control to add
  66128. * @returns the current container
  66129. */
  66130. addControl(control: BABYLON.Nullable<Control>): Container;
  66131. /**
  66132. * Removes a control from the current container
  66133. * @param control defines the control to remove
  66134. * @returns the current container
  66135. */
  66136. removeControl(control: Control): Container;
  66137. /** Gets the list of children */
  66138. readonly children: Control[];
  66139. _flagDescendantsAsMatrixDirty(): void;
  66140. /**
  66141. * Creates a new ScrollViewer
  66142. * @param name of ScrollViewer
  66143. */
  66144. constructor(name?: string);
  66145. /** Reset the scroll viewer window to initial size */
  66146. resetWindow(): void;
  66147. protected _getTypeName(): string;
  66148. private _buildClientSizes;
  66149. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  66150. protected _postMeasure(): void;
  66151. /**
  66152. * Gets or sets the mouse wheel precision
  66153. * from 0 to 1 with a default value of 0.05
  66154. * */
  66155. wheelPrecision: number;
  66156. /** Gets or sets the bar color */
  66157. barColor: string;
  66158. /** Gets or sets the size of the bar */
  66159. barSize: number;
  66160. /** Gets or sets the bar background */
  66161. barBackground: string;
  66162. /** @hidden */
  66163. private _updateScroller;
  66164. _link(host: AdvancedDynamicTexture): void;
  66165. /** @hidden */
  66166. private _attachWheel;
  66167. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  66168. /** Releases associated resources */
  66169. dispose(): void;
  66170. }
  66171. }
  66172. declare module BABYLON.GUI {
  66173. /** Class used to render a grid */
  66174. export class DisplayGrid extends Control {
  66175. name?: string | undefined;
  66176. private _cellWidth;
  66177. private _cellHeight;
  66178. private _minorLineTickness;
  66179. private _minorLineColor;
  66180. private _majorLineTickness;
  66181. private _majorLineColor;
  66182. private _majorLineFrequency;
  66183. private _background;
  66184. private _displayMajorLines;
  66185. private _displayMinorLines;
  66186. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  66187. displayMinorLines: boolean;
  66188. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  66189. displayMajorLines: boolean;
  66190. /** Gets or sets background color (Black by default) */
  66191. background: string;
  66192. /** Gets or sets the width of each cell (20 by default) */
  66193. cellWidth: number;
  66194. /** Gets or sets the height of each cell (20 by default) */
  66195. cellHeight: number;
  66196. /** Gets or sets the tickness of minor lines (1 by default) */
  66197. minorLineTickness: number;
  66198. /** Gets or sets the color of minor lines (DarkGray by default) */
  66199. minorLineColor: string;
  66200. /** Gets or sets the tickness of major lines (2 by default) */
  66201. majorLineTickness: number;
  66202. /** Gets or sets the color of major lines (White by default) */
  66203. majorLineColor: string;
  66204. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  66205. majorLineFrequency: number;
  66206. /**
  66207. * Creates a new GridDisplayRectangle
  66208. * @param name defines the control name
  66209. */
  66210. constructor(name?: string | undefined);
  66211. _draw(context: CanvasRenderingContext2D): void;
  66212. protected _getTypeName(): string;
  66213. }
  66214. }
  66215. declare module BABYLON.GUI {
  66216. /**
  66217. * Class used to create slider controls based on images
  66218. */
  66219. export class ImageBasedSlider extends BaseSlider {
  66220. name?: string | undefined;
  66221. private _backgroundImage;
  66222. private _thumbImage;
  66223. private _valueBarImage;
  66224. private _tempMeasure;
  66225. displayThumb: boolean;
  66226. /**
  66227. * Gets or sets the image used to render the background
  66228. */
  66229. backgroundImage: Image;
  66230. /**
  66231. * Gets or sets the image used to render the value bar
  66232. */
  66233. valueBarImage: Image;
  66234. /**
  66235. * Gets or sets the image used to render the thumb
  66236. */
  66237. thumbImage: Image;
  66238. /**
  66239. * Creates a new ImageBasedSlider
  66240. * @param name defines the control name
  66241. */
  66242. constructor(name?: string | undefined);
  66243. protected _getTypeName(): string;
  66244. _draw(context: CanvasRenderingContext2D): void;
  66245. }
  66246. }
  66247. declare module BABYLON.GUI {
  66248. /**
  66249. * Forcing an export so that this code will execute
  66250. * @hidden
  66251. */
  66252. const name = "Statics";
  66253. }
  66254. declare module BABYLON.GUI {
  66255. /**
  66256. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  66257. */
  66258. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  66259. /**
  66260. * Define the instrumented AdvancedDynamicTexture.
  66261. */
  66262. texture: AdvancedDynamicTexture;
  66263. private _captureRenderTime;
  66264. private _renderTime;
  66265. private _captureLayoutTime;
  66266. private _layoutTime;
  66267. private _onBeginRenderObserver;
  66268. private _onEndRenderObserver;
  66269. private _onBeginLayoutObserver;
  66270. private _onEndLayoutObserver;
  66271. /**
  66272. * Gets the perf counter used to capture render time
  66273. */
  66274. readonly renderTimeCounter: BABYLON.PerfCounter;
  66275. /**
  66276. * Gets the perf counter used to capture layout time
  66277. */
  66278. readonly layoutTimeCounter: BABYLON.PerfCounter;
  66279. /**
  66280. * Enable or disable the render time capture
  66281. */
  66282. captureRenderTime: boolean;
  66283. /**
  66284. * Enable or disable the layout time capture
  66285. */
  66286. captureLayoutTime: boolean;
  66287. /**
  66288. * Instantiates a new advanced dynamic texture instrumentation.
  66289. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  66290. * @param texture Defines the AdvancedDynamicTexture to instrument
  66291. */
  66292. constructor(
  66293. /**
  66294. * Define the instrumented AdvancedDynamicTexture.
  66295. */
  66296. texture: AdvancedDynamicTexture);
  66297. /**
  66298. * Dispose and release associated resources.
  66299. */
  66300. dispose(): void;
  66301. }
  66302. }
  66303. declare module BABYLON.GUI {
  66304. /**
  66305. * Class used to load GUI via XML.
  66306. */
  66307. export class XmlLoader {
  66308. private _nodes;
  66309. private _nodeTypes;
  66310. private _isLoaded;
  66311. private _objectAttributes;
  66312. private _parentClass;
  66313. /**
  66314. * Create a new xml loader
  66315. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  66316. */
  66317. constructor(parentClass?: null);
  66318. private _getChainElement;
  66319. private _getClassAttribute;
  66320. private _createGuiElement;
  66321. private _parseGrid;
  66322. private _parseElement;
  66323. private _prepareSourceElement;
  66324. private _parseElementsFromSource;
  66325. private _parseXml;
  66326. /**
  66327. * Gets if the loading has finished.
  66328. * @returns whether the loading has finished or not
  66329. */
  66330. isLoaded(): boolean;
  66331. /**
  66332. * Gets a loaded node / control by id.
  66333. * @param id the Controls id set in the xml
  66334. * @returns element of type Control
  66335. */
  66336. getNodeById(id: string): any;
  66337. /**
  66338. * Gets all loaded nodes / controls
  66339. * @returns Array of controls
  66340. */
  66341. getNodes(): any;
  66342. /**
  66343. * Initiates the xml layout loading
  66344. * @param xmlFile defines the xml layout to load
  66345. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  66346. * @param callback defines the callback called on layout load.
  66347. */
  66348. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  66349. }
  66350. }
  66351. declare module BABYLON.GUI {
  66352. /**
  66353. * Class used to create containers for controls
  66354. */
  66355. export class Container3D extends Control3D {
  66356. private _blockLayout;
  66357. /**
  66358. * Gets the list of child controls
  66359. */
  66360. protected _children: Control3D[];
  66361. /**
  66362. * Gets the list of child controls
  66363. */
  66364. readonly children: Array<Control3D>;
  66365. /**
  66366. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  66367. * This is helpful to optimize layout operation when adding multiple children in a row
  66368. */
  66369. blockLayout: boolean;
  66370. /**
  66371. * Creates a new container
  66372. * @param name defines the container name
  66373. */
  66374. constructor(name?: string);
  66375. /**
  66376. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  66377. * @returns the current container
  66378. */
  66379. updateLayout(): Container3D;
  66380. /**
  66381. * Gets a boolean indicating if the given control is in the children of this control
  66382. * @param control defines the control to check
  66383. * @returns true if the control is in the child list
  66384. */
  66385. containsControl(control: Control3D): boolean;
  66386. /**
  66387. * Adds a control to the children of this control
  66388. * @param control defines the control to add
  66389. * @returns the current container
  66390. */
  66391. addControl(control: Control3D): Container3D;
  66392. /**
  66393. * This function will be called everytime a new control is added
  66394. */
  66395. protected _arrangeChildren(): void;
  66396. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66397. /**
  66398. * Removes a control from the children of this control
  66399. * @param control defines the control to remove
  66400. * @returns the current container
  66401. */
  66402. removeControl(control: Control3D): Container3D;
  66403. protected _getTypeName(): string;
  66404. /**
  66405. * Releases all associated resources
  66406. */
  66407. dispose(): void;
  66408. /** Control rotation will remain unchanged */
  66409. static readonly UNSET_ORIENTATION: number;
  66410. /** Control will rotate to make it look at sphere central axis */
  66411. static readonly FACEORIGIN_ORIENTATION: number;
  66412. /** Control will rotate to make it look back at sphere central axis */
  66413. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  66414. /** Control will rotate to look at z axis (0, 0, 1) */
  66415. static readonly FACEFORWARD_ORIENTATION: number;
  66416. /** Control will rotate to look at negative z axis (0, 0, -1) */
  66417. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  66418. }
  66419. }
  66420. declare module BABYLON.GUI {
  66421. /**
  66422. * Class used to manage 3D user interface
  66423. * @see http://doc.babylonjs.com/how_to/gui3d
  66424. */
  66425. export class GUI3DManager implements BABYLON.IDisposable {
  66426. private _scene;
  66427. private _sceneDisposeObserver;
  66428. private _utilityLayer;
  66429. private _rootContainer;
  66430. private _pointerObserver;
  66431. private _pointerOutObserver;
  66432. /** @hidden */
  66433. _lastPickedControl: Control3D;
  66434. /** @hidden */
  66435. _lastControlOver: {
  66436. [pointerId: number]: Control3D;
  66437. };
  66438. /** @hidden */
  66439. _lastControlDown: {
  66440. [pointerId: number]: Control3D;
  66441. };
  66442. /**
  66443. * BABYLON.Observable raised when the point picked by the pointer events changed
  66444. */
  66445. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  66446. /** @hidden */
  66447. _sharedMaterials: {
  66448. [key: string]: BABYLON.Material;
  66449. };
  66450. /** Gets the hosting scene */
  66451. readonly scene: BABYLON.Scene;
  66452. /** Gets associated utility layer */
  66453. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  66454. /**
  66455. * Creates a new GUI3DManager
  66456. * @param scene
  66457. */
  66458. constructor(scene?: BABYLON.Scene);
  66459. private _handlePointerOut;
  66460. private _doPicking;
  66461. /**
  66462. * Gets the root container
  66463. */
  66464. readonly rootContainer: Container3D;
  66465. /**
  66466. * Gets a boolean indicating if the given control is in the root child list
  66467. * @param control defines the control to check
  66468. * @returns true if the control is in the root child list
  66469. */
  66470. containsControl(control: Control3D): boolean;
  66471. /**
  66472. * Adds a control to the root child list
  66473. * @param control defines the control to add
  66474. * @returns the current manager
  66475. */
  66476. addControl(control: Control3D): GUI3DManager;
  66477. /**
  66478. * Removes a control from the root child list
  66479. * @param control defines the control to remove
  66480. * @returns the current container
  66481. */
  66482. removeControl(control: Control3D): GUI3DManager;
  66483. /**
  66484. * Releases all associated resources
  66485. */
  66486. dispose(): void;
  66487. }
  66488. }
  66489. declare module BABYLON.GUI {
  66490. /**
  66491. * Class used to transport BABYLON.Vector3 information for pointer events
  66492. */
  66493. export class Vector3WithInfo extends BABYLON.Vector3 {
  66494. /** defines the current mouse button index */
  66495. buttonIndex: number;
  66496. /**
  66497. * Creates a new Vector3WithInfo
  66498. * @param source defines the vector3 data to transport
  66499. * @param buttonIndex defines the current mouse button index
  66500. */
  66501. constructor(source: BABYLON.Vector3,
  66502. /** defines the current mouse button index */
  66503. buttonIndex?: number);
  66504. }
  66505. }
  66506. declare module BABYLON.GUI {
  66507. /**
  66508. * Class used as base class for controls
  66509. */
  66510. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  66511. /** Defines the control name */
  66512. name?: string | undefined;
  66513. /** @hidden */
  66514. _host: GUI3DManager;
  66515. private _node;
  66516. private _downCount;
  66517. private _enterCount;
  66518. private _downPointerIds;
  66519. private _isVisible;
  66520. /** Gets or sets the control position in world space */
  66521. position: BABYLON.Vector3;
  66522. /** Gets or sets the control scaling in world space */
  66523. scaling: BABYLON.Vector3;
  66524. /** Callback used to start pointer enter animation */
  66525. pointerEnterAnimation: () => void;
  66526. /** Callback used to start pointer out animation */
  66527. pointerOutAnimation: () => void;
  66528. /** Callback used to start pointer down animation */
  66529. pointerDownAnimation: () => void;
  66530. /** Callback used to start pointer up animation */
  66531. pointerUpAnimation: () => void;
  66532. /**
  66533. * An event triggered when the pointer move over the control
  66534. */
  66535. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  66536. /**
  66537. * An event triggered when the pointer move out of the control
  66538. */
  66539. onPointerOutObservable: BABYLON.Observable<Control3D>;
  66540. /**
  66541. * An event triggered when the pointer taps the control
  66542. */
  66543. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  66544. /**
  66545. * An event triggered when pointer is up
  66546. */
  66547. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  66548. /**
  66549. * An event triggered when a control is clicked on (with a mouse)
  66550. */
  66551. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  66552. /**
  66553. * An event triggered when pointer enters the control
  66554. */
  66555. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  66556. /**
  66557. * Gets or sets the parent container
  66558. */
  66559. parent: BABYLON.Nullable<Container3D>;
  66560. private _behaviors;
  66561. /**
  66562. * Gets the list of attached behaviors
  66563. * @see http://doc.babylonjs.com/features/behaviour
  66564. */
  66565. readonly behaviors: BABYLON.Behavior<Control3D>[];
  66566. /**
  66567. * Attach a behavior to the control
  66568. * @see http://doc.babylonjs.com/features/behaviour
  66569. * @param behavior defines the behavior to attach
  66570. * @returns the current control
  66571. */
  66572. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66573. /**
  66574. * Remove an attached behavior
  66575. * @see http://doc.babylonjs.com/features/behaviour
  66576. * @param behavior defines the behavior to attach
  66577. * @returns the current control
  66578. */
  66579. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  66580. /**
  66581. * Gets an attached behavior by name
  66582. * @param name defines the name of the behavior to look for
  66583. * @see http://doc.babylonjs.com/features/behaviour
  66584. * @returns null if behavior was not found else the requested behavior
  66585. */
  66586. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  66587. /** Gets or sets a boolean indicating if the control is visible */
  66588. isVisible: boolean;
  66589. /**
  66590. * Creates a new control
  66591. * @param name defines the control name
  66592. */
  66593. constructor(
  66594. /** Defines the control name */
  66595. name?: string | undefined);
  66596. /**
  66597. * Gets a string representing the class name
  66598. */
  66599. readonly typeName: string;
  66600. /**
  66601. * Get the current class name of the control.
  66602. * @returns current class name
  66603. */
  66604. getClassName(): string;
  66605. protected _getTypeName(): string;
  66606. /**
  66607. * Gets the transform node used by this control
  66608. */
  66609. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  66610. /**
  66611. * Gets the mesh used to render this control
  66612. */
  66613. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66614. /**
  66615. * Link the control as child of the given node
  66616. * @param node defines the node to link to. Use null to unlink the control
  66617. * @returns the current control
  66618. */
  66619. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66620. /** @hidden **/
  66621. _prepareNode(scene: BABYLON.Scene): void;
  66622. /**
  66623. * Node creation.
  66624. * Can be overriden by children
  66625. * @param scene defines the scene where the node must be attached
  66626. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66627. */
  66628. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66629. /**
  66630. * Affect a material to the given mesh
  66631. * @param mesh defines the mesh which will represent the control
  66632. */
  66633. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66634. /** @hidden */
  66635. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66636. /** @hidden */
  66637. _onPointerEnter(target: Control3D): boolean;
  66638. /** @hidden */
  66639. _onPointerOut(target: Control3D): void;
  66640. /** @hidden */
  66641. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66642. /** @hidden */
  66643. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66644. /** @hidden */
  66645. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66646. /** @hidden */
  66647. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66648. /** @hidden */
  66649. _disposeNode(): void;
  66650. /**
  66651. * Releases all associated resources
  66652. */
  66653. dispose(): void;
  66654. }
  66655. }
  66656. declare module BABYLON.GUI {
  66657. /**
  66658. * Class used as a root to all buttons
  66659. */
  66660. export class AbstractButton3D extends Control3D {
  66661. /**
  66662. * Creates a new button
  66663. * @param name defines the control name
  66664. */
  66665. constructor(name?: string);
  66666. protected _getTypeName(): string;
  66667. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66668. }
  66669. }
  66670. declare module BABYLON.GUI {
  66671. /**
  66672. * Class used to create a button in 3D
  66673. */
  66674. export class Button3D extends AbstractButton3D {
  66675. /** @hidden */
  66676. protected _currentMaterial: BABYLON.Material;
  66677. private _facadeTexture;
  66678. private _content;
  66679. private _contentResolution;
  66680. private _contentScaleRatio;
  66681. /**
  66682. * Gets or sets the texture resolution used to render content (512 by default)
  66683. */
  66684. contentResolution: BABYLON.int;
  66685. /**
  66686. * Gets or sets the texture scale ratio used to render content (2 by default)
  66687. */
  66688. contentScaleRatio: number;
  66689. protected _disposeFacadeTexture(): void;
  66690. protected _resetContent(): void;
  66691. /**
  66692. * Creates a new button
  66693. * @param name defines the control name
  66694. */
  66695. constructor(name?: string);
  66696. /**
  66697. * Gets or sets the GUI 2D content used to display the button's facade
  66698. */
  66699. content: Control;
  66700. /**
  66701. * Apply the facade texture (created from the content property).
  66702. * This function can be overloaded by child classes
  66703. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66704. */
  66705. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66706. protected _getTypeName(): string;
  66707. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66708. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66709. /**
  66710. * Releases all associated resources
  66711. */
  66712. dispose(): void;
  66713. }
  66714. }
  66715. declare module BABYLON.GUI {
  66716. /**
  66717. * Abstract class used to create a container panel deployed on the surface of a volume
  66718. */
  66719. export abstract class VolumeBasedPanel extends Container3D {
  66720. private _columns;
  66721. private _rows;
  66722. private _rowThenColum;
  66723. private _orientation;
  66724. protected _cellWidth: number;
  66725. protected _cellHeight: number;
  66726. /**
  66727. * Gets or sets the distance between elements
  66728. */
  66729. margin: number;
  66730. /**
  66731. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66732. * | Value | Type | Description |
  66733. * | ----- | ----------------------------------- | ----------- |
  66734. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66735. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66736. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66737. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66738. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66739. */
  66740. orientation: number;
  66741. /**
  66742. * Gets or sets the number of columns requested (10 by default).
  66743. * The panel will automatically compute the number of rows based on number of child controls.
  66744. */
  66745. columns: BABYLON.int;
  66746. /**
  66747. * Gets or sets a the number of rows requested.
  66748. * The panel will automatically compute the number of columns based on number of child controls.
  66749. */
  66750. rows: BABYLON.int;
  66751. /**
  66752. * Creates new VolumeBasedPanel
  66753. */
  66754. constructor();
  66755. protected _arrangeChildren(): void;
  66756. /** Child classes must implement this function to provide correct control positioning */
  66757. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66758. /** Child classes can implement this function to provide additional processing */
  66759. protected _finalProcessing(): void;
  66760. }
  66761. }
  66762. declare module BABYLON.GUI {
  66763. /**
  66764. * Class used to create a container panel deployed on the surface of a cylinder
  66765. */
  66766. export class CylinderPanel extends VolumeBasedPanel {
  66767. private _radius;
  66768. /**
  66769. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66770. */
  66771. radius: BABYLON.float;
  66772. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66773. private _cylindricalMapping;
  66774. }
  66775. }
  66776. declare module BABYLON.GUI {
  66777. /** @hidden */
  66778. export var fluentVertexShader: {
  66779. name: string;
  66780. shader: string;
  66781. };
  66782. }
  66783. declare module BABYLON.GUI {
  66784. /** @hidden */
  66785. export var fluentPixelShader: {
  66786. name: string;
  66787. shader: string;
  66788. };
  66789. }
  66790. declare module BABYLON.GUI {
  66791. /** @hidden */
  66792. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66793. INNERGLOW: boolean;
  66794. BORDER: boolean;
  66795. HOVERLIGHT: boolean;
  66796. TEXTURE: boolean;
  66797. constructor();
  66798. }
  66799. /**
  66800. * Class used to render controls with fluent desgin
  66801. */
  66802. export class FluentMaterial extends BABYLON.PushMaterial {
  66803. /**
  66804. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66805. */
  66806. innerGlowColorIntensity: number;
  66807. /**
  66808. * Gets or sets the inner glow color (white by default)
  66809. */
  66810. innerGlowColor: BABYLON.Color3;
  66811. /**
  66812. * Gets or sets alpha value (default is 1.0)
  66813. */
  66814. alpha: number;
  66815. /**
  66816. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66817. */
  66818. albedoColor: BABYLON.Color3;
  66819. /**
  66820. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66821. */
  66822. renderBorders: boolean;
  66823. /**
  66824. * Gets or sets border width (default is 0.5)
  66825. */
  66826. borderWidth: number;
  66827. /**
  66828. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66829. */
  66830. edgeSmoothingValue: number;
  66831. /**
  66832. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66833. */
  66834. borderMinValue: number;
  66835. /**
  66836. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66837. */
  66838. renderHoverLight: boolean;
  66839. /**
  66840. * Gets or sets the radius used to render the hover light (default is 1.0)
  66841. */
  66842. hoverRadius: number;
  66843. /**
  66844. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66845. */
  66846. hoverColor: BABYLON.Color4;
  66847. /**
  66848. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66849. */
  66850. hoverPosition: BABYLON.Vector3;
  66851. private _albedoTexture;
  66852. /** Gets or sets the texture to use for albedo color */
  66853. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66854. /**
  66855. * Creates a new Fluent material
  66856. * @param name defines the name of the material
  66857. * @param scene defines the hosting scene
  66858. */
  66859. constructor(name: string, scene: BABYLON.Scene);
  66860. needAlphaBlending(): boolean;
  66861. needAlphaTesting(): boolean;
  66862. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66863. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66864. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66865. getActiveTextures(): BABYLON.BaseTexture[];
  66866. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66867. dispose(forceDisposeEffect?: boolean): void;
  66868. clone(name: string): FluentMaterial;
  66869. serialize(): any;
  66870. getClassName(): string;
  66871. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66872. }
  66873. }
  66874. declare module BABYLON.GUI {
  66875. /**
  66876. * Class used to create a holographic button in 3D
  66877. */
  66878. export class HolographicButton extends Button3D {
  66879. private _backPlate;
  66880. private _textPlate;
  66881. private _frontPlate;
  66882. private _text;
  66883. private _imageUrl;
  66884. private _shareMaterials;
  66885. private _frontMaterial;
  66886. private _backMaterial;
  66887. private _plateMaterial;
  66888. private _pickedPointObserver;
  66889. private _tooltipFade;
  66890. private _tooltipTextBlock;
  66891. private _tooltipTexture;
  66892. private _tooltipMesh;
  66893. private _tooltipHoverObserver;
  66894. private _tooltipOutObserver;
  66895. private _disposeTooltip;
  66896. /**
  66897. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66898. */
  66899. tooltipText: BABYLON.Nullable<string>;
  66900. /**
  66901. * Gets or sets text for the button
  66902. */
  66903. text: string;
  66904. /**
  66905. * Gets or sets the image url for the button
  66906. */
  66907. imageUrl: string;
  66908. /**
  66909. * Gets the back material used by this button
  66910. */
  66911. readonly backMaterial: FluentMaterial;
  66912. /**
  66913. * Gets the front material used by this button
  66914. */
  66915. readonly frontMaterial: FluentMaterial;
  66916. /**
  66917. * Gets the plate material used by this button
  66918. */
  66919. readonly plateMaterial: BABYLON.StandardMaterial;
  66920. /**
  66921. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66922. */
  66923. readonly shareMaterials: boolean;
  66924. /**
  66925. * Creates a new button
  66926. * @param name defines the control name
  66927. */
  66928. constructor(name?: string, shareMaterials?: boolean);
  66929. protected _getTypeName(): string;
  66930. private _rebuildContent;
  66931. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66932. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66933. private _createBackMaterial;
  66934. private _createFrontMaterial;
  66935. private _createPlateMaterial;
  66936. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66937. /**
  66938. * Releases all associated resources
  66939. */
  66940. dispose(): void;
  66941. }
  66942. }
  66943. declare module BABYLON.GUI {
  66944. /**
  66945. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66946. */
  66947. export class MeshButton3D extends Button3D {
  66948. /** @hidden */
  66949. protected _currentMesh: BABYLON.Mesh;
  66950. /**
  66951. * Creates a new 3D button based on a mesh
  66952. * @param mesh mesh to become a 3D button
  66953. * @param name defines the control name
  66954. */
  66955. constructor(mesh: BABYLON.Mesh, name?: string);
  66956. protected _getTypeName(): string;
  66957. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66958. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66959. }
  66960. }
  66961. declare module BABYLON.GUI {
  66962. /**
  66963. * Class used to create a container panel deployed on the surface of a plane
  66964. */
  66965. export class PlanePanel extends VolumeBasedPanel {
  66966. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66967. }
  66968. }
  66969. declare module BABYLON.GUI {
  66970. /**
  66971. * Class used to create a container panel where items get randomized planar mapping
  66972. */
  66973. export class ScatterPanel extends VolumeBasedPanel {
  66974. private _iteration;
  66975. /**
  66976. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66977. */
  66978. iteration: BABYLON.float;
  66979. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66980. private _scatterMapping;
  66981. protected _finalProcessing(): void;
  66982. }
  66983. }
  66984. declare module BABYLON.GUI {
  66985. /**
  66986. * Class used to create a container panel deployed on the surface of a sphere
  66987. */
  66988. export class SpherePanel extends VolumeBasedPanel {
  66989. private _radius;
  66990. /**
  66991. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66992. */
  66993. radius: BABYLON.float;
  66994. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66995. private _sphericalMapping;
  66996. }
  66997. }
  66998. declare module BABYLON.GUI {
  66999. /**
  67000. * Class used to create a stack panel in 3D on XY plane
  67001. */
  67002. export class StackPanel3D extends Container3D {
  67003. private _isVertical;
  67004. /**
  67005. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  67006. */
  67007. isVertical: boolean;
  67008. /**
  67009. * Gets or sets the distance between elements
  67010. */
  67011. margin: number;
  67012. /**
  67013. * Creates new StackPanel
  67014. * @param isVertical
  67015. */
  67016. constructor(isVertical?: boolean);
  67017. protected _arrangeChildren(): void;
  67018. }
  67019. }
  67020. declare module BABYLON {
  67021. /**
  67022. * Mode that determines the coordinate system to use.
  67023. */
  67024. export enum GLTFLoaderCoordinateSystemMode {
  67025. /**
  67026. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  67027. */
  67028. AUTO = 0,
  67029. /**
  67030. * Sets the useRightHandedSystem flag on the scene.
  67031. */
  67032. FORCE_RIGHT_HANDED = 1
  67033. }
  67034. /**
  67035. * Mode that determines what animations will start.
  67036. */
  67037. export enum GLTFLoaderAnimationStartMode {
  67038. /**
  67039. * No animation will start.
  67040. */
  67041. NONE = 0,
  67042. /**
  67043. * The first animation will start.
  67044. */
  67045. FIRST = 1,
  67046. /**
  67047. * All animations will start.
  67048. */
  67049. ALL = 2
  67050. }
  67051. /**
  67052. * Interface that contains the data for the glTF asset.
  67053. */
  67054. export interface IGLTFLoaderData {
  67055. /**
  67056. * Object that represents the glTF JSON.
  67057. */
  67058. json: Object;
  67059. /**
  67060. * The BIN chunk of a binary glTF.
  67061. */
  67062. bin: Nullable<ArrayBufferView>;
  67063. }
  67064. /**
  67065. * Interface for extending the loader.
  67066. */
  67067. export interface IGLTFLoaderExtension {
  67068. /**
  67069. * The name of this extension.
  67070. */
  67071. readonly name: string;
  67072. /**
  67073. * Defines whether this extension is enabled.
  67074. */
  67075. enabled: boolean;
  67076. }
  67077. /**
  67078. * Loader state.
  67079. */
  67080. export enum GLTFLoaderState {
  67081. /**
  67082. * The asset is loading.
  67083. */
  67084. LOADING = 0,
  67085. /**
  67086. * The asset is ready for rendering.
  67087. */
  67088. READY = 1,
  67089. /**
  67090. * The asset is completely loaded.
  67091. */
  67092. COMPLETE = 2
  67093. }
  67094. /** @hidden */
  67095. export interface IGLTFLoader extends IDisposable {
  67096. readonly state: Nullable<GLTFLoaderState>;
  67097. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  67098. meshes: AbstractMesh[];
  67099. particleSystems: IParticleSystem[];
  67100. skeletons: Skeleton[];
  67101. animationGroups: AnimationGroup[];
  67102. }>;
  67103. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  67104. }
  67105. /**
  67106. * File loader for loading glTF files into a scene.
  67107. */
  67108. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  67109. /** @hidden */
  67110. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67111. /** @hidden */
  67112. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  67113. /**
  67114. * Raised when the asset has been parsed
  67115. */
  67116. onParsedObservable: Observable<IGLTFLoaderData>;
  67117. private _onParsedObserver;
  67118. /**
  67119. * Raised when the asset has been parsed
  67120. */
  67121. onParsed: (loaderData: IGLTFLoaderData) => void;
  67122. /**
  67123. * 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.
  67124. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  67125. * Defaults to true.
  67126. * @hidden
  67127. */
  67128. static IncrementalLoading: boolean;
  67129. /**
  67130. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  67131. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  67132. * @hidden
  67133. */
  67134. static HomogeneousCoordinates: boolean;
  67135. /**
  67136. * The coordinate system mode. Defaults to AUTO.
  67137. */
  67138. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  67139. /**
  67140. * The animation start mode. Defaults to FIRST.
  67141. */
  67142. animationStartMode: GLTFLoaderAnimationStartMode;
  67143. /**
  67144. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  67145. */
  67146. compileMaterials: boolean;
  67147. /**
  67148. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  67149. */
  67150. useClipPlane: boolean;
  67151. /**
  67152. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  67153. */
  67154. compileShadowGenerators: boolean;
  67155. /**
  67156. * Defines if the Alpha blended materials are only applied as coverage.
  67157. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  67158. * If true, no extra effects are applied to transparent pixels.
  67159. */
  67160. transparencyAsCoverage: boolean;
  67161. /**
  67162. * Function called before loading a url referenced by the asset.
  67163. */
  67164. preprocessUrlAsync: (url: string) => Promise<string>;
  67165. /**
  67166. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67167. */
  67168. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  67169. private _onMeshLoadedObserver;
  67170. /**
  67171. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67172. */
  67173. onMeshLoaded: (mesh: AbstractMesh) => void;
  67174. /**
  67175. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  67176. */
  67177. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  67178. private _onTextureLoadedObserver;
  67179. /**
  67180. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  67181. */
  67182. onTextureLoaded: (texture: BaseTexture) => void;
  67183. /**
  67184. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  67185. */
  67186. readonly onMaterialLoadedObservable: Observable<Material>;
  67187. private _onMaterialLoadedObserver;
  67188. /**
  67189. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  67190. */
  67191. onMaterialLoaded: (material: Material) => void;
  67192. /**
  67193. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  67194. */
  67195. readonly onCameraLoadedObservable: Observable<Camera>;
  67196. private _onCameraLoadedObserver;
  67197. /**
  67198. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  67199. */
  67200. onCameraLoaded: (camera: Camera) => void;
  67201. /**
  67202. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  67203. * For assets with LODs, raised when all of the LODs are complete.
  67204. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67205. */
  67206. readonly onCompleteObservable: Observable<void>;
  67207. private _onCompleteObserver;
  67208. /**
  67209. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  67210. * For assets with LODs, raised when all of the LODs are complete.
  67211. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  67212. */
  67213. onComplete: () => void;
  67214. /**
  67215. * Observable raised when an error occurs.
  67216. */
  67217. readonly onErrorObservable: Observable<any>;
  67218. private _onErrorObserver;
  67219. /**
  67220. * Callback raised when an error occurs.
  67221. */
  67222. onError: (reason: any) => void;
  67223. /**
  67224. * Observable raised after the loader is disposed.
  67225. */
  67226. readonly onDisposeObservable: Observable<void>;
  67227. private _onDisposeObserver;
  67228. /**
  67229. * Callback raised after the loader is disposed.
  67230. */
  67231. onDispose: () => void;
  67232. /**
  67233. * Observable raised after a loader extension is created.
  67234. * Set additional options for a loader extension in this event.
  67235. */
  67236. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  67237. private _onExtensionLoadedObserver;
  67238. /**
  67239. * Callback raised after a loader extension is created.
  67240. */
  67241. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  67242. /**
  67243. * Defines if the loader logging is enabled.
  67244. */
  67245. loggingEnabled: boolean;
  67246. /**
  67247. * Defines if the loader should capture performance counters.
  67248. */
  67249. capturePerformanceCounters: boolean;
  67250. /**
  67251. * Defines if the loader should validate the asset.
  67252. */
  67253. validate: boolean;
  67254. /**
  67255. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  67256. */
  67257. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  67258. private _onValidatedObserver;
  67259. /**
  67260. * Callback raised after a loader extension is created.
  67261. */
  67262. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  67263. private _loader;
  67264. /**
  67265. * Name of the loader ("gltf")
  67266. */
  67267. name: string;
  67268. /**
  67269. * Supported file extensions of the loader (.gltf, .glb)
  67270. */
  67271. extensions: ISceneLoaderPluginExtensions;
  67272. /**
  67273. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  67274. */
  67275. dispose(): void;
  67276. /** @hidden */
  67277. _clear(): void;
  67278. /**
  67279. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  67280. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67281. * @param scene the scene the meshes should be added to
  67282. * @param data the glTF data to load
  67283. * @param rootUrl root url to load from
  67284. * @param onProgress event that fires when loading progress has occured
  67285. * @param fileName Defines the name of the file to load
  67286. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67287. */
  67288. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67289. meshes: AbstractMesh[];
  67290. particleSystems: IParticleSystem[];
  67291. skeletons: Skeleton[];
  67292. animationGroups: AnimationGroup[];
  67293. }>;
  67294. /**
  67295. * Imports all objects from the loaded glTF data and adds them to the scene
  67296. * @param scene the scene the objects should be added to
  67297. * @param data the glTF data to load
  67298. * @param rootUrl root url to load from
  67299. * @param onProgress event that fires when loading progress has occured
  67300. * @param fileName Defines the name of the file to load
  67301. * @returns a promise which completes when objects have been loaded to the scene
  67302. */
  67303. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67304. /**
  67305. * Load into an asset container.
  67306. * @param scene The scene to load into
  67307. * @param data The data to import
  67308. * @param rootUrl The root url for scene and resources
  67309. * @param onProgress The callback when the load progresses
  67310. * @param fileName Defines the name of the file to load
  67311. * @returns The loaded asset container
  67312. */
  67313. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  67314. /**
  67315. * If the data string can be loaded directly.
  67316. * @param data string contianing the file data
  67317. * @returns if the data can be loaded directly
  67318. */
  67319. canDirectLoad(data: string): boolean;
  67320. /**
  67321. * Rewrites a url by combining a root url and response url.
  67322. */
  67323. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  67324. /**
  67325. * Instantiates a glTF file loader plugin.
  67326. * @returns the created plugin
  67327. */
  67328. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  67329. /**
  67330. * The loader state or null if the loader is not active.
  67331. */
  67332. readonly loaderState: Nullable<GLTFLoaderState>;
  67333. /**
  67334. * Returns a promise that resolves when the asset is completely loaded.
  67335. * @returns a promise that resolves when the asset is completely loaded.
  67336. */
  67337. whenCompleteAsync(): Promise<void>;
  67338. private _parseAsync;
  67339. private _validateAsync;
  67340. private _getLoader;
  67341. private _unpackBinary;
  67342. private _unpackBinaryV1;
  67343. private _unpackBinaryV2;
  67344. private static _parseVersion;
  67345. private static _compareVersion;
  67346. private static _decodeBufferToText;
  67347. private static readonly _logSpaces;
  67348. private _logIndentLevel;
  67349. private _loggingEnabled;
  67350. /** @hidden */
  67351. _log: (message: string) => void;
  67352. /** @hidden */
  67353. _logOpen(message: string): void;
  67354. /** @hidden */
  67355. _logClose(): void;
  67356. private _logEnabled;
  67357. private _logDisabled;
  67358. private _capturePerformanceCounters;
  67359. /** @hidden */
  67360. _startPerformanceCounter: (counterName: string) => void;
  67361. /** @hidden */
  67362. _endPerformanceCounter: (counterName: string) => void;
  67363. private _startPerformanceCounterEnabled;
  67364. private _startPerformanceCounterDisabled;
  67365. private _endPerformanceCounterEnabled;
  67366. private _endPerformanceCounterDisabled;
  67367. }
  67368. }
  67369. declare module BABYLON.GLTF1 {
  67370. /**
  67371. * Enums
  67372. * @hidden
  67373. */
  67374. export enum EComponentType {
  67375. BYTE = 5120,
  67376. UNSIGNED_BYTE = 5121,
  67377. SHORT = 5122,
  67378. UNSIGNED_SHORT = 5123,
  67379. FLOAT = 5126
  67380. }
  67381. /** @hidden */
  67382. export enum EShaderType {
  67383. FRAGMENT = 35632,
  67384. VERTEX = 35633
  67385. }
  67386. /** @hidden */
  67387. export enum EParameterType {
  67388. BYTE = 5120,
  67389. UNSIGNED_BYTE = 5121,
  67390. SHORT = 5122,
  67391. UNSIGNED_SHORT = 5123,
  67392. INT = 5124,
  67393. UNSIGNED_INT = 5125,
  67394. FLOAT = 5126,
  67395. FLOAT_VEC2 = 35664,
  67396. FLOAT_VEC3 = 35665,
  67397. FLOAT_VEC4 = 35666,
  67398. INT_VEC2 = 35667,
  67399. INT_VEC3 = 35668,
  67400. INT_VEC4 = 35669,
  67401. BOOL = 35670,
  67402. BOOL_VEC2 = 35671,
  67403. BOOL_VEC3 = 35672,
  67404. BOOL_VEC4 = 35673,
  67405. FLOAT_MAT2 = 35674,
  67406. FLOAT_MAT3 = 35675,
  67407. FLOAT_MAT4 = 35676,
  67408. SAMPLER_2D = 35678
  67409. }
  67410. /** @hidden */
  67411. export enum ETextureWrapMode {
  67412. CLAMP_TO_EDGE = 33071,
  67413. MIRRORED_REPEAT = 33648,
  67414. REPEAT = 10497
  67415. }
  67416. /** @hidden */
  67417. export enum ETextureFilterType {
  67418. NEAREST = 9728,
  67419. LINEAR = 9728,
  67420. NEAREST_MIPMAP_NEAREST = 9984,
  67421. LINEAR_MIPMAP_NEAREST = 9985,
  67422. NEAREST_MIPMAP_LINEAR = 9986,
  67423. LINEAR_MIPMAP_LINEAR = 9987
  67424. }
  67425. /** @hidden */
  67426. export enum ETextureFormat {
  67427. ALPHA = 6406,
  67428. RGB = 6407,
  67429. RGBA = 6408,
  67430. LUMINANCE = 6409,
  67431. LUMINANCE_ALPHA = 6410
  67432. }
  67433. /** @hidden */
  67434. export enum ECullingType {
  67435. FRONT = 1028,
  67436. BACK = 1029,
  67437. FRONT_AND_BACK = 1032
  67438. }
  67439. /** @hidden */
  67440. export enum EBlendingFunction {
  67441. ZERO = 0,
  67442. ONE = 1,
  67443. SRC_COLOR = 768,
  67444. ONE_MINUS_SRC_COLOR = 769,
  67445. DST_COLOR = 774,
  67446. ONE_MINUS_DST_COLOR = 775,
  67447. SRC_ALPHA = 770,
  67448. ONE_MINUS_SRC_ALPHA = 771,
  67449. DST_ALPHA = 772,
  67450. ONE_MINUS_DST_ALPHA = 773,
  67451. CONSTANT_COLOR = 32769,
  67452. ONE_MINUS_CONSTANT_COLOR = 32770,
  67453. CONSTANT_ALPHA = 32771,
  67454. ONE_MINUS_CONSTANT_ALPHA = 32772,
  67455. SRC_ALPHA_SATURATE = 776
  67456. }
  67457. /** @hidden */
  67458. export interface IGLTFProperty {
  67459. extensions?: {
  67460. [key: string]: any;
  67461. };
  67462. extras?: Object;
  67463. }
  67464. /** @hidden */
  67465. export interface IGLTFChildRootProperty extends IGLTFProperty {
  67466. name?: string;
  67467. }
  67468. /** @hidden */
  67469. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  67470. bufferView: string;
  67471. byteOffset: number;
  67472. byteStride: number;
  67473. count: number;
  67474. type: string;
  67475. componentType: EComponentType;
  67476. max?: number[];
  67477. min?: number[];
  67478. name?: string;
  67479. }
  67480. /** @hidden */
  67481. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  67482. buffer: string;
  67483. byteOffset: number;
  67484. byteLength: number;
  67485. byteStride: number;
  67486. target?: number;
  67487. }
  67488. /** @hidden */
  67489. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  67490. uri: string;
  67491. byteLength?: number;
  67492. type?: string;
  67493. }
  67494. /** @hidden */
  67495. export interface IGLTFShader extends IGLTFChildRootProperty {
  67496. uri: string;
  67497. type: EShaderType;
  67498. }
  67499. /** @hidden */
  67500. export interface IGLTFProgram extends IGLTFChildRootProperty {
  67501. attributes: string[];
  67502. fragmentShader: string;
  67503. vertexShader: string;
  67504. }
  67505. /** @hidden */
  67506. export interface IGLTFTechniqueParameter {
  67507. type: number;
  67508. count?: number;
  67509. semantic?: string;
  67510. node?: string;
  67511. value?: number | boolean | string | Array<any>;
  67512. source?: string;
  67513. babylonValue?: any;
  67514. }
  67515. /** @hidden */
  67516. export interface IGLTFTechniqueCommonProfile {
  67517. lightingModel: string;
  67518. texcoordBindings: Object;
  67519. parameters?: Array<any>;
  67520. }
  67521. /** @hidden */
  67522. export interface IGLTFTechniqueStatesFunctions {
  67523. blendColor?: number[];
  67524. blendEquationSeparate?: number[];
  67525. blendFuncSeparate?: number[];
  67526. colorMask: boolean[];
  67527. cullFace: number[];
  67528. }
  67529. /** @hidden */
  67530. export interface IGLTFTechniqueStates {
  67531. enable: number[];
  67532. functions: IGLTFTechniqueStatesFunctions;
  67533. }
  67534. /** @hidden */
  67535. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  67536. parameters: {
  67537. [key: string]: IGLTFTechniqueParameter;
  67538. };
  67539. program: string;
  67540. attributes: {
  67541. [key: string]: string;
  67542. };
  67543. uniforms: {
  67544. [key: string]: string;
  67545. };
  67546. states: IGLTFTechniqueStates;
  67547. }
  67548. /** @hidden */
  67549. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  67550. technique?: string;
  67551. values: string[];
  67552. }
  67553. /** @hidden */
  67554. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  67555. attributes: {
  67556. [key: string]: string;
  67557. };
  67558. indices: string;
  67559. material: string;
  67560. mode?: number;
  67561. }
  67562. /** @hidden */
  67563. export interface IGLTFMesh extends IGLTFChildRootProperty {
  67564. primitives: IGLTFMeshPrimitive[];
  67565. }
  67566. /** @hidden */
  67567. export interface IGLTFImage extends IGLTFChildRootProperty {
  67568. uri: string;
  67569. }
  67570. /** @hidden */
  67571. export interface IGLTFSampler extends IGLTFChildRootProperty {
  67572. magFilter?: number;
  67573. minFilter?: number;
  67574. wrapS?: number;
  67575. wrapT?: number;
  67576. }
  67577. /** @hidden */
  67578. export interface IGLTFTexture extends IGLTFChildRootProperty {
  67579. sampler: string;
  67580. source: string;
  67581. format?: ETextureFormat;
  67582. internalFormat?: ETextureFormat;
  67583. target?: number;
  67584. type?: number;
  67585. babylonTexture?: Texture;
  67586. }
  67587. /** @hidden */
  67588. export interface IGLTFAmbienLight {
  67589. color?: number[];
  67590. }
  67591. /** @hidden */
  67592. export interface IGLTFDirectionalLight {
  67593. color?: number[];
  67594. }
  67595. /** @hidden */
  67596. export interface IGLTFPointLight {
  67597. color?: number[];
  67598. constantAttenuation?: number;
  67599. linearAttenuation?: number;
  67600. quadraticAttenuation?: number;
  67601. }
  67602. /** @hidden */
  67603. export interface IGLTFSpotLight {
  67604. color?: number[];
  67605. constantAttenuation?: number;
  67606. fallOfAngle?: number;
  67607. fallOffExponent?: number;
  67608. linearAttenuation?: number;
  67609. quadraticAttenuation?: number;
  67610. }
  67611. /** @hidden */
  67612. export interface IGLTFLight extends IGLTFChildRootProperty {
  67613. type: string;
  67614. }
  67615. /** @hidden */
  67616. export interface IGLTFCameraOrthographic {
  67617. xmag: number;
  67618. ymag: number;
  67619. zfar: number;
  67620. znear: number;
  67621. }
  67622. /** @hidden */
  67623. export interface IGLTFCameraPerspective {
  67624. aspectRatio: number;
  67625. yfov: number;
  67626. zfar: number;
  67627. znear: number;
  67628. }
  67629. /** @hidden */
  67630. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67631. type: string;
  67632. }
  67633. /** @hidden */
  67634. export interface IGLTFAnimationChannelTarget {
  67635. id: string;
  67636. path: string;
  67637. }
  67638. /** @hidden */
  67639. export interface IGLTFAnimationChannel {
  67640. sampler: string;
  67641. target: IGLTFAnimationChannelTarget;
  67642. }
  67643. /** @hidden */
  67644. export interface IGLTFAnimationSampler {
  67645. input: string;
  67646. output: string;
  67647. interpolation?: string;
  67648. }
  67649. /** @hidden */
  67650. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67651. channels?: IGLTFAnimationChannel[];
  67652. parameters?: {
  67653. [key: string]: string;
  67654. };
  67655. samplers?: {
  67656. [key: string]: IGLTFAnimationSampler;
  67657. };
  67658. }
  67659. /** @hidden */
  67660. export interface IGLTFNodeInstanceSkin {
  67661. skeletons: string[];
  67662. skin: string;
  67663. meshes: string[];
  67664. }
  67665. /** @hidden */
  67666. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67667. bindShapeMatrix: number[];
  67668. inverseBindMatrices: string;
  67669. jointNames: string[];
  67670. babylonSkeleton?: Skeleton;
  67671. }
  67672. /** @hidden */
  67673. export interface IGLTFNode extends IGLTFChildRootProperty {
  67674. camera?: string;
  67675. children: string[];
  67676. skin?: string;
  67677. jointName?: string;
  67678. light?: string;
  67679. matrix: number[];
  67680. mesh?: string;
  67681. meshes?: string[];
  67682. rotation?: number[];
  67683. scale?: number[];
  67684. translation?: number[];
  67685. babylonNode?: Node;
  67686. }
  67687. /** @hidden */
  67688. export interface IGLTFScene extends IGLTFChildRootProperty {
  67689. nodes: string[];
  67690. }
  67691. /** @hidden */
  67692. export interface IGLTFRuntime {
  67693. extensions: {
  67694. [key: string]: any;
  67695. };
  67696. accessors: {
  67697. [key: string]: IGLTFAccessor;
  67698. };
  67699. buffers: {
  67700. [key: string]: IGLTFBuffer;
  67701. };
  67702. bufferViews: {
  67703. [key: string]: IGLTFBufferView;
  67704. };
  67705. meshes: {
  67706. [key: string]: IGLTFMesh;
  67707. };
  67708. lights: {
  67709. [key: string]: IGLTFLight;
  67710. };
  67711. cameras: {
  67712. [key: string]: IGLTFCamera;
  67713. };
  67714. nodes: {
  67715. [key: string]: IGLTFNode;
  67716. };
  67717. images: {
  67718. [key: string]: IGLTFImage;
  67719. };
  67720. textures: {
  67721. [key: string]: IGLTFTexture;
  67722. };
  67723. shaders: {
  67724. [key: string]: IGLTFShader;
  67725. };
  67726. programs: {
  67727. [key: string]: IGLTFProgram;
  67728. };
  67729. samplers: {
  67730. [key: string]: IGLTFSampler;
  67731. };
  67732. techniques: {
  67733. [key: string]: IGLTFTechnique;
  67734. };
  67735. materials: {
  67736. [key: string]: IGLTFMaterial;
  67737. };
  67738. animations: {
  67739. [key: string]: IGLTFAnimation;
  67740. };
  67741. skins: {
  67742. [key: string]: IGLTFSkins;
  67743. };
  67744. currentScene?: Object;
  67745. scenes: {
  67746. [key: string]: IGLTFScene;
  67747. };
  67748. extensionsUsed: string[];
  67749. extensionsRequired?: string[];
  67750. buffersCount: number;
  67751. shaderscount: number;
  67752. scene: Scene;
  67753. rootUrl: string;
  67754. loadedBufferCount: number;
  67755. loadedBufferViews: {
  67756. [name: string]: ArrayBufferView;
  67757. };
  67758. loadedShaderCount: number;
  67759. importOnlyMeshes: boolean;
  67760. importMeshesNames?: string[];
  67761. dummyNodes: Node[];
  67762. }
  67763. /** @hidden */
  67764. export interface INodeToRoot {
  67765. bone: Bone;
  67766. node: IGLTFNode;
  67767. id: string;
  67768. }
  67769. /** @hidden */
  67770. export interface IJointNode {
  67771. node: IGLTFNode;
  67772. id: string;
  67773. }
  67774. }
  67775. declare module BABYLON.GLTF1 {
  67776. /**
  67777. * Utils functions for GLTF
  67778. * @hidden
  67779. */
  67780. export class GLTFUtils {
  67781. /**
  67782. * Sets the given "parameter" matrix
  67783. * @param scene: the Scene object
  67784. * @param source: the source node where to pick the matrix
  67785. * @param parameter: the GLTF technique parameter
  67786. * @param uniformName: the name of the shader's uniform
  67787. * @param shaderMaterial: the shader material
  67788. */
  67789. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67790. /**
  67791. * Sets the given "parameter" matrix
  67792. * @param shaderMaterial: the shader material
  67793. * @param uniform: the name of the shader's uniform
  67794. * @param value: the value of the uniform
  67795. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67796. */
  67797. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67798. /**
  67799. * Returns the wrap mode of the texture
  67800. * @param mode: the mode value
  67801. */
  67802. static GetWrapMode(mode: number): number;
  67803. /**
  67804. * Returns the byte stride giving an accessor
  67805. * @param accessor: the GLTF accessor objet
  67806. */
  67807. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67808. /**
  67809. * Returns the texture filter mode giving a mode value
  67810. * @param mode: the filter mode value
  67811. */
  67812. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67813. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67814. /**
  67815. * Returns a buffer from its accessor
  67816. * @param gltfRuntime: the GLTF runtime
  67817. * @param accessor: the GLTF accessor
  67818. */
  67819. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67820. /**
  67821. * Decodes a buffer view into a string
  67822. * @param view: the buffer view
  67823. */
  67824. static DecodeBufferToText(view: ArrayBufferView): string;
  67825. /**
  67826. * Returns the default material of gltf. Related to
  67827. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67828. * @param scene: the Babylon.js scene
  67829. */
  67830. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67831. private static _DefaultMaterial;
  67832. }
  67833. }
  67834. declare module BABYLON.GLTF1 {
  67835. /**
  67836. * Implementation of the base glTF spec
  67837. * @hidden
  67838. */
  67839. export class GLTFLoaderBase {
  67840. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67841. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67842. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67843. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67844. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67845. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67846. }
  67847. /**
  67848. * glTF V1 Loader
  67849. * @hidden
  67850. */
  67851. export class GLTFLoader implements IGLTFLoader {
  67852. static Extensions: {
  67853. [name: string]: GLTFLoaderExtension;
  67854. };
  67855. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67856. state: Nullable<GLTFLoaderState>;
  67857. dispose(): void;
  67858. private _importMeshAsync;
  67859. /**
  67860. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67861. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67862. * @param scene the scene the meshes should be added to
  67863. * @param data gltf data containing information of the meshes in a loaded file
  67864. * @param rootUrl root url to load from
  67865. * @param onProgress event that fires when loading progress has occured
  67866. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67867. */
  67868. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67869. meshes: AbstractMesh[];
  67870. particleSystems: IParticleSystem[];
  67871. skeletons: Skeleton[];
  67872. animationGroups: AnimationGroup[];
  67873. }>;
  67874. private _loadAsync;
  67875. /**
  67876. * Imports all objects from a loaded gltf file and adds them to the scene
  67877. * @param scene the scene the objects should be added to
  67878. * @param data gltf data containing information of the meshes in a loaded file
  67879. * @param rootUrl root url to load from
  67880. * @param onProgress event that fires when loading progress has occured
  67881. * @returns a promise which completes when objects have been loaded to the scene
  67882. */
  67883. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67884. private _loadShadersAsync;
  67885. private _loadBuffersAsync;
  67886. private _createNodes;
  67887. }
  67888. /** @hidden */
  67889. export abstract class GLTFLoaderExtension {
  67890. private _name;
  67891. constructor(name: string);
  67892. readonly name: string;
  67893. /**
  67894. * Defines an override for loading the runtime
  67895. * Return true to stop further extensions from loading the runtime
  67896. */
  67897. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67898. /**
  67899. * Defines an onverride for creating gltf runtime
  67900. * Return true to stop further extensions from creating the runtime
  67901. */
  67902. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67903. /**
  67904. * Defines an override for loading buffers
  67905. * Return true to stop further extensions from loading this buffer
  67906. */
  67907. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67908. /**
  67909. * Defines an override for loading texture buffers
  67910. * Return true to stop further extensions from loading this texture data
  67911. */
  67912. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67913. /**
  67914. * Defines an override for creating textures
  67915. * Return true to stop further extensions from loading this texture
  67916. */
  67917. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67918. /**
  67919. * Defines an override for loading shader strings
  67920. * Return true to stop further extensions from loading this shader data
  67921. */
  67922. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67923. /**
  67924. * Defines an override for loading materials
  67925. * Return true to stop further extensions from loading this material
  67926. */
  67927. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67928. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67929. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67930. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67931. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67932. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67933. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67934. private static LoadTextureBufferAsync;
  67935. private static CreateTextureAsync;
  67936. private static ApplyExtensions;
  67937. }
  67938. }
  67939. declare module BABYLON.GLTF1 {
  67940. /** @hidden */
  67941. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67942. private _bin;
  67943. constructor();
  67944. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67945. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67946. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67947. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67948. }
  67949. }
  67950. declare module BABYLON.GLTF1 {
  67951. /** @hidden */
  67952. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67953. constructor();
  67954. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67955. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67956. private _loadTexture;
  67957. }
  67958. }
  67959. declare module BABYLON.GLTF2.Loader {
  67960. /**
  67961. * Loader interface with an index field.
  67962. */
  67963. export interface IArrayItem {
  67964. /**
  67965. * The index of this item in the array.
  67966. */
  67967. index: number;
  67968. }
  67969. /**
  67970. * Loader interface with additional members.
  67971. */
  67972. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67973. /** @hidden */
  67974. _data?: Promise<ArrayBufferView>;
  67975. /** @hidden */
  67976. _babylonVertexBuffer?: Promise<VertexBuffer>;
  67977. }
  67978. /**
  67979. * Loader interface with additional members.
  67980. */
  67981. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67982. }
  67983. /** @hidden */
  67984. export interface _IAnimationSamplerData {
  67985. input: Float32Array;
  67986. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67987. output: Float32Array;
  67988. }
  67989. /**
  67990. * Loader interface with additional members.
  67991. */
  67992. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67993. /** @hidden */
  67994. _data?: Promise<_IAnimationSamplerData>;
  67995. }
  67996. /**
  67997. * Loader interface with additional members.
  67998. */
  67999. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  68000. channels: IAnimationChannel[];
  68001. samplers: IAnimationSampler[];
  68002. /** @hidden */
  68003. _babylonAnimationGroup?: AnimationGroup;
  68004. }
  68005. /**
  68006. * Loader interface with additional members.
  68007. */
  68008. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  68009. /** @hidden */
  68010. _data?: Promise<ArrayBufferView>;
  68011. }
  68012. /**
  68013. * Loader interface with additional members.
  68014. */
  68015. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  68016. /** @hidden */
  68017. _data?: Promise<ArrayBufferView>;
  68018. /** @hidden */
  68019. _babylonBuffer?: Promise<Buffer>;
  68020. }
  68021. /**
  68022. * Loader interface with additional members.
  68023. */
  68024. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  68025. }
  68026. /**
  68027. * Loader interface with additional members.
  68028. */
  68029. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  68030. /** @hidden */
  68031. _data?: Promise<ArrayBufferView>;
  68032. }
  68033. /**
  68034. * Loader interface with additional members.
  68035. */
  68036. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  68037. }
  68038. /**
  68039. * Loader interface with additional members.
  68040. */
  68041. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  68042. }
  68043. /**
  68044. * Loader interface with additional members.
  68045. */
  68046. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  68047. baseColorTexture?: ITextureInfo;
  68048. metallicRoughnessTexture?: ITextureInfo;
  68049. }
  68050. /**
  68051. * Loader interface with additional members.
  68052. */
  68053. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  68054. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68055. normalTexture?: IMaterialNormalTextureInfo;
  68056. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68057. emissiveTexture?: ITextureInfo;
  68058. /** @hidden */
  68059. _data?: {
  68060. [babylonDrawMode: number]: {
  68061. babylonMaterial: Material;
  68062. babylonMeshes: AbstractMesh[];
  68063. promise: Promise<void>;
  68064. };
  68065. };
  68066. }
  68067. /**
  68068. * Loader interface with additional members.
  68069. */
  68070. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  68071. primitives: IMeshPrimitive[];
  68072. }
  68073. /**
  68074. * Loader interface with additional members.
  68075. */
  68076. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  68077. /** @hidden */
  68078. _instanceData?: {
  68079. babylonSourceMesh: Mesh;
  68080. promise: Promise<any>;
  68081. };
  68082. }
  68083. /**
  68084. * Loader interface with additional members.
  68085. */
  68086. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  68087. /**
  68088. * The parent glTF node.
  68089. */
  68090. parent?: INode;
  68091. /** @hidden */
  68092. _babylonTransformNode?: TransformNode;
  68093. /** @hidden */
  68094. _primitiveBabylonMeshes?: AbstractMesh[];
  68095. /** @hidden */
  68096. _babylonBones?: Bone[];
  68097. /** @hidden */
  68098. _numMorphTargets?: number;
  68099. }
  68100. /** @hidden */
  68101. export interface _ISamplerData {
  68102. noMipMaps: boolean;
  68103. samplingMode: number;
  68104. wrapU: number;
  68105. wrapV: number;
  68106. }
  68107. /**
  68108. * Loader interface with additional members.
  68109. */
  68110. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  68111. /** @hidden */
  68112. _data?: _ISamplerData;
  68113. }
  68114. /**
  68115. * Loader interface with additional members.
  68116. */
  68117. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  68118. }
  68119. /**
  68120. * Loader interface with additional members.
  68121. */
  68122. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  68123. /** @hidden */
  68124. _data?: {
  68125. babylonSkeleton: Skeleton;
  68126. promise: Promise<void>;
  68127. };
  68128. }
  68129. /**
  68130. * Loader interface with additional members.
  68131. */
  68132. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  68133. }
  68134. /**
  68135. * Loader interface with additional members.
  68136. */
  68137. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  68138. }
  68139. /**
  68140. * Loader interface with additional members.
  68141. */
  68142. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  68143. accessors?: IAccessor[];
  68144. animations?: IAnimation[];
  68145. buffers?: IBuffer[];
  68146. bufferViews?: IBufferView[];
  68147. cameras?: ICamera[];
  68148. images?: IImage[];
  68149. materials?: IMaterial[];
  68150. meshes?: IMesh[];
  68151. nodes?: INode[];
  68152. samplers?: ISampler[];
  68153. scenes?: IScene[];
  68154. skins?: ISkin[];
  68155. textures?: ITexture[];
  68156. }
  68157. }
  68158. declare module BABYLON.GLTF2 {
  68159. /**
  68160. * Interface for a glTF loader extension.
  68161. */
  68162. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  68163. /**
  68164. * Called after the loader state changes to LOADING.
  68165. */
  68166. onLoading?(): void;
  68167. /**
  68168. * Called after the loader state changes to READY.
  68169. */
  68170. onReady?(): void;
  68171. /**
  68172. * Define this method to modify the default behavior when loading scenes.
  68173. * @param context The context when loading the asset
  68174. * @param scene The glTF scene property
  68175. * @returns A promise that resolves when the load is complete or null if not handled
  68176. */
  68177. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  68178. /**
  68179. * Define this method to modify the default behavior when loading nodes.
  68180. * @param context The context when loading the asset
  68181. * @param node The glTF node property
  68182. * @param assign A function called synchronously after parsing the glTF properties
  68183. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  68184. */
  68185. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68186. /**
  68187. * Define this method to modify the default behavior when loading cameras.
  68188. * @param context The context when loading the asset
  68189. * @param camera The glTF camera property
  68190. * @param assign A function called synchronously after parsing the glTF properties
  68191. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  68192. */
  68193. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68194. /**
  68195. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  68196. * @param context The context when loading the asset
  68197. * @param primitive The glTF mesh primitive property
  68198. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  68199. */
  68200. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68201. /**
  68202. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68203. * @param context The context when loading the asset
  68204. * @param name The mesh name when loading the asset
  68205. * @param node The glTF node when loading the asset
  68206. * @param mesh The glTF mesh when loading the asset
  68207. * @param primitive The glTF mesh primitive property
  68208. * @param assign A function called synchronously after parsing the glTF properties
  68209. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68210. */
  68211. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68212. /**
  68213. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  68214. * @param context The context when loading the asset
  68215. * @param material The glTF material property
  68216. * @param assign A function called synchronously after parsing the glTF properties
  68217. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  68218. */
  68219. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68220. /**
  68221. * Define this method to modify the default behavior when creating materials.
  68222. * @param context The context when loading the asset
  68223. * @param material The glTF material property
  68224. * @param babylonDrawMode The draw mode for the Babylon material
  68225. * @returns The Babylon material or null if not handled
  68226. */
  68227. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68228. /**
  68229. * Define this method to modify the default behavior when loading material properties.
  68230. * @param context The context when loading the asset
  68231. * @param material The glTF material property
  68232. * @param babylonMaterial The Babylon material
  68233. * @returns A promise that resolves when the load is complete or null if not handled
  68234. */
  68235. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68236. /**
  68237. * Define this method to modify the default behavior when loading texture infos.
  68238. * @param context The context when loading the asset
  68239. * @param textureInfo The glTF texture info property
  68240. * @param assign A function called synchronously after parsing the glTF properties
  68241. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  68242. */
  68243. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68244. /**
  68245. * Define this method to modify the default behavior when loading animations.
  68246. * @param context The context when loading the asset
  68247. * @param animation The glTF animation property
  68248. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  68249. */
  68250. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68251. /**
  68252. * @hidden Define this method to modify the default behavior when loading skins.
  68253. * @param context The context when loading the asset
  68254. * @param node The glTF node property
  68255. * @param skin The glTF skin property
  68256. * @returns A promise that resolves when the load is complete or null if not handled
  68257. */
  68258. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  68259. /**
  68260. * @hidden Define this method to modify the default behavior when loading uris.
  68261. * @param context The context when loading the asset
  68262. * @param property The glTF property associated with the uri
  68263. * @param uri The uri to load
  68264. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  68265. */
  68266. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68267. }
  68268. }
  68269. declare module BABYLON.GLTF2 {
  68270. /**
  68271. * Helper class for working with arrays when loading the glTF asset
  68272. */
  68273. export class ArrayItem {
  68274. /**
  68275. * Gets an item from the given array.
  68276. * @param context The context when loading the asset
  68277. * @param array The array to get the item from
  68278. * @param index The index to the array
  68279. * @returns The array item
  68280. */
  68281. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  68282. /**
  68283. * Assign an `index` field to each item of the given array.
  68284. * @param array The array of items
  68285. */
  68286. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  68287. }
  68288. /**
  68289. * The glTF 2.0 loader
  68290. */
  68291. export class GLTFLoader implements IGLTFLoader {
  68292. /** @hidden */
  68293. _completePromises: Promise<any>[];
  68294. private _disposed;
  68295. private _parent;
  68296. private _state;
  68297. private _extensions;
  68298. private _rootUrl;
  68299. private _fileName;
  68300. private _uniqueRootUrl;
  68301. private _gltf;
  68302. private _babylonScene;
  68303. private _rootBabylonMesh;
  68304. private _defaultBabylonMaterialData;
  68305. private _progressCallback?;
  68306. private _requests;
  68307. private static readonly _DefaultSampler;
  68308. private static _ExtensionNames;
  68309. private static _ExtensionFactories;
  68310. /**
  68311. * Registers a loader extension.
  68312. * @param name The name of the loader extension.
  68313. * @param factory The factory function that creates the loader extension.
  68314. */
  68315. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  68316. /**
  68317. * Unregisters a loader extension.
  68318. * @param name The name of the loader extenion.
  68319. * @returns A boolean indicating whether the extension has been unregistered
  68320. */
  68321. static UnregisterExtension(name: string): boolean;
  68322. /**
  68323. * Gets the loader state.
  68324. */
  68325. readonly state: Nullable<GLTFLoaderState>;
  68326. /**
  68327. * The glTF object parsed from the JSON.
  68328. */
  68329. readonly gltf: IGLTF;
  68330. /**
  68331. * The Babylon scene when loading the asset.
  68332. */
  68333. readonly babylonScene: Scene;
  68334. /**
  68335. * The root Babylon mesh when loading the asset.
  68336. */
  68337. readonly rootBabylonMesh: Mesh;
  68338. /** @hidden */
  68339. constructor(parent: GLTFFileLoader);
  68340. /** @hidden */
  68341. dispose(): void;
  68342. /** @hidden */
  68343. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68344. meshes: AbstractMesh[];
  68345. particleSystems: IParticleSystem[];
  68346. skeletons: Skeleton[];
  68347. animationGroups: AnimationGroup[];
  68348. }>;
  68349. /** @hidden */
  68350. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68351. private _loadAsync;
  68352. private _loadData;
  68353. private _setupData;
  68354. private _loadExtensions;
  68355. private _checkExtensions;
  68356. private _setState;
  68357. private _createRootNode;
  68358. /**
  68359. * Loads a glTF scene.
  68360. * @param context The context when loading the asset
  68361. * @param scene The glTF scene property
  68362. * @returns A promise that resolves when the load is complete
  68363. */
  68364. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  68365. private _forEachPrimitive;
  68366. private _getMeshes;
  68367. private _getSkeletons;
  68368. private _getAnimationGroups;
  68369. private _startAnimations;
  68370. /**
  68371. * Loads a glTF node.
  68372. * @param context The context when loading the asset
  68373. * @param node The glTF node property
  68374. * @param assign A function called synchronously after parsing the glTF properties
  68375. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  68376. */
  68377. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  68378. private _loadMeshAsync;
  68379. /**
  68380. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  68381. * @param context The context when loading the asset
  68382. * @param name The mesh name when loading the asset
  68383. * @param node The glTF node when loading the asset
  68384. * @param mesh The glTF mesh when loading the asset
  68385. * @param primitive The glTF mesh primitive property
  68386. * @param assign A function called synchronously after parsing the glTF properties
  68387. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  68388. */
  68389. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  68390. private _loadVertexDataAsync;
  68391. private _createMorphTargets;
  68392. private _loadMorphTargetsAsync;
  68393. private _loadMorphTargetVertexDataAsync;
  68394. private static _LoadTransform;
  68395. private _loadSkinAsync;
  68396. private _loadBones;
  68397. private _loadBone;
  68398. private _loadSkinInverseBindMatricesDataAsync;
  68399. private _updateBoneMatrices;
  68400. private _getNodeMatrix;
  68401. /**
  68402. * Loads a glTF camera.
  68403. * @param context The context when loading the asset
  68404. * @param camera The glTF camera property
  68405. * @param assign A function called synchronously after parsing the glTF properties
  68406. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  68407. */
  68408. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  68409. private _loadAnimationsAsync;
  68410. /**
  68411. * Loads a glTF animation.
  68412. * @param context The context when loading the asset
  68413. * @param animation The glTF animation property
  68414. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  68415. */
  68416. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  68417. /**
  68418. * @hidden Loads a glTF animation channel.
  68419. * @param context The context when loading the asset
  68420. * @param animationContext The context of the animation when loading the asset
  68421. * @param animation The glTF animation property
  68422. * @param channel The glTF animation channel property
  68423. * @param babylonAnimationGroup The babylon animation group property
  68424. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  68425. * @returns A void promise when the channel load is complete
  68426. */
  68427. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  68428. private _loadAnimationSamplerAsync;
  68429. private _loadBufferAsync;
  68430. /**
  68431. * Loads a glTF buffer view.
  68432. * @param context The context when loading the asset
  68433. * @param bufferView The glTF buffer view property
  68434. * @returns A promise that resolves with the loaded data when the load is complete
  68435. */
  68436. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  68437. private _loadAccessorAsync;
  68438. private _loadFloatAccessorAsync;
  68439. private _loadIndicesAccessorAsync;
  68440. private _loadVertexBufferViewAsync;
  68441. private _loadVertexAccessorAsync;
  68442. private _loadMaterialMetallicRoughnessPropertiesAsync;
  68443. /** @hidden */
  68444. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  68445. private _createDefaultMaterial;
  68446. /**
  68447. * Creates a Babylon material from a glTF material.
  68448. * @param context The context when loading the asset
  68449. * @param material The glTF material property
  68450. * @param babylonDrawMode The draw mode for the Babylon material
  68451. * @returns The Babylon material
  68452. */
  68453. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  68454. /**
  68455. * Loads properties from a glTF material into a Babylon material.
  68456. * @param context The context when loading the asset
  68457. * @param material The glTF material property
  68458. * @param babylonMaterial The Babylon material
  68459. * @returns A promise that resolves when the load is complete
  68460. */
  68461. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68462. /**
  68463. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  68464. * @param context The context when loading the asset
  68465. * @param material The glTF material property
  68466. * @param babylonMaterial The Babylon material
  68467. * @returns A promise that resolves when the load is complete
  68468. */
  68469. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  68470. /**
  68471. * Loads the alpha properties from a glTF material into a Babylon material.
  68472. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  68473. * @param context The context when loading the asset
  68474. * @param material The glTF material property
  68475. * @param babylonMaterial The Babylon material
  68476. */
  68477. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  68478. /**
  68479. * Loads a glTF texture info.
  68480. * @param context The context when loading the asset
  68481. * @param textureInfo The glTF texture info property
  68482. * @param assign A function called synchronously after parsing the glTF properties
  68483. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  68484. */
  68485. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  68486. private _loadTextureAsync;
  68487. private _loadSampler;
  68488. /**
  68489. * Loads a glTF image.
  68490. * @param context The context when loading the asset
  68491. * @param image The glTF image property
  68492. * @returns A promise that resolves with the loaded data when the load is complete
  68493. */
  68494. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  68495. /**
  68496. * Loads a glTF uri.
  68497. * @param context The context when loading the asset
  68498. * @param property The glTF property associated with the uri
  68499. * @param uri The base64 or relative uri
  68500. * @returns A promise that resolves with the loaded data when the load is complete
  68501. */
  68502. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  68503. private _onProgress;
  68504. /**
  68505. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  68506. * @param babylonObject the Babylon object with metadata
  68507. * @param pointer the JSON pointer
  68508. */
  68509. static AddPointerMetadata(babylonObject: {
  68510. metadata: any;
  68511. }, pointer: string): void;
  68512. private static _GetTextureWrapMode;
  68513. private static _GetTextureSamplingMode;
  68514. private static _GetTypedArrayConstructor;
  68515. private static _GetTypedArray;
  68516. private static _GetNumComponents;
  68517. private static _ValidateUri;
  68518. private static _GetDrawMode;
  68519. private _compileMaterialsAsync;
  68520. private _compileShadowGeneratorsAsync;
  68521. private _forEachExtensions;
  68522. private _applyExtensions;
  68523. private _extensionsOnLoading;
  68524. private _extensionsOnReady;
  68525. private _extensionsLoadSceneAsync;
  68526. private _extensionsLoadNodeAsync;
  68527. private _extensionsLoadCameraAsync;
  68528. private _extensionsLoadVertexDataAsync;
  68529. private _extensionsLoadMeshPrimitiveAsync;
  68530. private _extensionsLoadMaterialAsync;
  68531. private _extensionsCreateMaterial;
  68532. private _extensionsLoadMaterialPropertiesAsync;
  68533. private _extensionsLoadTextureInfoAsync;
  68534. private _extensionsLoadAnimationAsync;
  68535. private _extensionsLoadSkinAsync;
  68536. private _extensionsLoadUriAsync;
  68537. /**
  68538. * Helper method called by a loader extension to load an glTF extension.
  68539. * @param context The context when loading the asset
  68540. * @param property The glTF property to load the extension from
  68541. * @param extensionName The name of the extension to load
  68542. * @param actionAsync The action to run
  68543. * @returns The promise returned by actionAsync or null if the extension does not exist
  68544. */
  68545. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68546. /**
  68547. * Helper method called by a loader extension to load a glTF extra.
  68548. * @param context The context when loading the asset
  68549. * @param property The glTF property to load the extra from
  68550. * @param extensionName The name of the extension to load
  68551. * @param actionAsync The action to run
  68552. * @returns The promise returned by actionAsync or null if the extra does not exist
  68553. */
  68554. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  68555. /**
  68556. * Increments the indentation level and logs a message.
  68557. * @param message The message to log
  68558. */
  68559. logOpen(message: string): void;
  68560. /**
  68561. * Decrements the indentation level.
  68562. */
  68563. logClose(): void;
  68564. /**
  68565. * Logs a message
  68566. * @param message The message to log
  68567. */
  68568. log(message: string): void;
  68569. /**
  68570. * Starts a performance counter.
  68571. * @param counterName The name of the performance counter
  68572. */
  68573. startPerformanceCounter(counterName: string): void;
  68574. /**
  68575. * Ends a performance counter.
  68576. * @param counterName The name of the performance counter
  68577. */
  68578. endPerformanceCounter(counterName: string): void;
  68579. }
  68580. }
  68581. declare module BABYLON.GLTF2.Loader.Extensions {
  68582. /**
  68583. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  68584. */
  68585. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  68586. /** The name of this extension. */
  68587. readonly name: string;
  68588. /** Defines whether this extension is enabled. */
  68589. enabled: boolean;
  68590. private _loader;
  68591. private _lights?;
  68592. /** @hidden */
  68593. constructor(loader: GLTFLoader);
  68594. /** @hidden */
  68595. dispose(): void;
  68596. /** @hidden */
  68597. onLoading(): void;
  68598. /** @hidden */
  68599. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68600. private _loadLightAsync;
  68601. }
  68602. }
  68603. declare module BABYLON.GLTF2.Loader.Extensions {
  68604. /**
  68605. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  68606. */
  68607. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  68608. /** The name of this extension. */
  68609. readonly name: string;
  68610. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  68611. dracoCompression?: DracoCompression;
  68612. /** Defines whether this extension is enabled. */
  68613. enabled: boolean;
  68614. private _loader;
  68615. /** @hidden */
  68616. constructor(loader: GLTFLoader);
  68617. /** @hidden */
  68618. dispose(): void;
  68619. /** @hidden */
  68620. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  68621. }
  68622. }
  68623. declare module BABYLON.GLTF2.Loader.Extensions {
  68624. /**
  68625. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  68626. */
  68627. export class KHR_lights implements IGLTFLoaderExtension {
  68628. /** The name of this extension. */
  68629. readonly name: string;
  68630. /** Defines whether this extension is enabled. */
  68631. enabled: boolean;
  68632. private _loader;
  68633. private _lights?;
  68634. /** @hidden */
  68635. constructor(loader: GLTFLoader);
  68636. /** @hidden */
  68637. dispose(): void;
  68638. /** @hidden */
  68639. onLoading(): void;
  68640. /** @hidden */
  68641. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68642. }
  68643. }
  68644. declare module BABYLON.GLTF2.Loader.Extensions {
  68645. /**
  68646. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  68647. */
  68648. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  68649. /** The name of this extension. */
  68650. readonly name: string;
  68651. /** Defines whether this extension is enabled. */
  68652. enabled: boolean;
  68653. private _loader;
  68654. /** @hidden */
  68655. constructor(loader: GLTFLoader);
  68656. /** @hidden */
  68657. dispose(): void;
  68658. /** @hidden */
  68659. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68660. private _loadSpecularGlossinessPropertiesAsync;
  68661. }
  68662. }
  68663. declare module BABYLON.GLTF2.Loader.Extensions {
  68664. /**
  68665. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68666. */
  68667. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68668. /** The name of this extension. */
  68669. readonly name: string;
  68670. /** Defines whether this extension is enabled. */
  68671. enabled: boolean;
  68672. private _loader;
  68673. /** @hidden */
  68674. constructor(loader: GLTFLoader);
  68675. /** @hidden */
  68676. dispose(): void;
  68677. /** @hidden */
  68678. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68679. private _loadUnlitPropertiesAsync;
  68680. }
  68681. }
  68682. declare module BABYLON.GLTF2.Loader.Extensions {
  68683. /**
  68684. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68685. */
  68686. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68687. /** The name of this extension. */
  68688. readonly name: string;
  68689. /** Defines whether this extension is enabled. */
  68690. enabled: boolean;
  68691. private _loader;
  68692. /** @hidden */
  68693. constructor(loader: GLTFLoader);
  68694. /** @hidden */
  68695. dispose(): void;
  68696. /** @hidden */
  68697. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68698. }
  68699. }
  68700. declare module BABYLON.GLTF2.Loader.Extensions {
  68701. /**
  68702. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68703. */
  68704. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68705. /** The name of this extension. */
  68706. readonly name: string;
  68707. /** Defines whether this extension is enabled. */
  68708. enabled: boolean;
  68709. private _loader;
  68710. private _clips;
  68711. private _emitters;
  68712. /** @hidden */
  68713. constructor(loader: GLTFLoader);
  68714. /** @hidden */
  68715. dispose(): void;
  68716. /** @hidden */
  68717. onLoading(): void;
  68718. /** @hidden */
  68719. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68720. /** @hidden */
  68721. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68722. /** @hidden */
  68723. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68724. private _loadClipAsync;
  68725. private _loadEmitterAsync;
  68726. private _getEventAction;
  68727. private _loadAnimationEventAsync;
  68728. }
  68729. }
  68730. declare module BABYLON.GLTF2.Loader.Extensions {
  68731. /**
  68732. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68733. */
  68734. export class MSFT_lod implements IGLTFLoaderExtension {
  68735. /** The name of this extension. */
  68736. readonly name: string;
  68737. /** Defines whether this extension is enabled. */
  68738. enabled: boolean;
  68739. /**
  68740. * Maximum number of LODs to load, starting from the lowest LOD.
  68741. */
  68742. maxLODsToLoad: number;
  68743. /**
  68744. * Observable raised when all node LODs of one level are loaded.
  68745. * The event data is the index of the loaded LOD starting from zero.
  68746. * Dispose the loader to cancel the loading of the next level of LODs.
  68747. */
  68748. onNodeLODsLoadedObservable: Observable<number>;
  68749. /**
  68750. * Observable raised when all material LODs of one level are loaded.
  68751. * The event data is the index of the loaded LOD starting from zero.
  68752. * Dispose the loader to cancel the loading of the next level of LODs.
  68753. */
  68754. onMaterialLODsLoadedObservable: Observable<number>;
  68755. private _loader;
  68756. private _nodeIndexLOD;
  68757. private _nodeSignalLODs;
  68758. private _nodePromiseLODs;
  68759. private _materialIndexLOD;
  68760. private _materialSignalLODs;
  68761. private _materialPromiseLODs;
  68762. /** @hidden */
  68763. constructor(loader: GLTFLoader);
  68764. /** @hidden */
  68765. dispose(): void;
  68766. /** @hidden */
  68767. onReady(): void;
  68768. /** @hidden */
  68769. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68770. /** @hidden */
  68771. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68772. /** @hidden */
  68773. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68774. /**
  68775. * Gets an array of LOD properties from lowest to highest.
  68776. */
  68777. private _getLODs;
  68778. private _disposeUnusedMaterials;
  68779. }
  68780. }
  68781. declare module BABYLON.GLTF2.Loader.Extensions {
  68782. /** @hidden */
  68783. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68784. readonly name: string;
  68785. enabled: boolean;
  68786. private _loader;
  68787. constructor(loader: GLTFLoader);
  68788. dispose(): void;
  68789. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68790. }
  68791. }
  68792. declare module BABYLON.GLTF2.Loader.Extensions {
  68793. /** @hidden */
  68794. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68795. readonly name: string;
  68796. enabled: boolean;
  68797. private _loader;
  68798. constructor(loader: GLTFLoader);
  68799. dispose(): void;
  68800. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68801. }
  68802. }
  68803. declare module BABYLON.GLTF2.Loader.Extensions {
  68804. /**
  68805. * Store glTF extras (if present) in BJS objects' metadata
  68806. */
  68807. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68808. /** The name of this extension. */
  68809. readonly name: string;
  68810. /** Defines whether this extension is enabled. */
  68811. enabled: boolean;
  68812. private _loader;
  68813. private _assignExtras;
  68814. /** @hidden */
  68815. constructor(loader: GLTFLoader);
  68816. /** @hidden */
  68817. dispose(): void;
  68818. /** @hidden */
  68819. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68820. /** @hidden */
  68821. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68822. /** @hidden */
  68823. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68824. }
  68825. }
  68826. declare module BABYLON {
  68827. /**
  68828. * Class reading and parsing the MTL file bundled with the obj file.
  68829. */
  68830. export class MTLFileLoader {
  68831. /**
  68832. * All material loaded from the mtl will be set here
  68833. */
  68834. materials: StandardMaterial[];
  68835. /**
  68836. * This function will read the mtl file and create each material described inside
  68837. * This function could be improve by adding :
  68838. * -some component missing (Ni, Tf...)
  68839. * -including the specific options available
  68840. *
  68841. * @param scene defines the scene the material will be created in
  68842. * @param data defines the mtl data to parse
  68843. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68844. */
  68845. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68846. /**
  68847. * Gets the texture for the material.
  68848. *
  68849. * If the material is imported from input file,
  68850. * We sanitize the url to ensure it takes the textre from aside the material.
  68851. *
  68852. * @param rootUrl The root url to load from
  68853. * @param value The value stored in the mtl
  68854. * @return The Texture
  68855. */
  68856. private static _getTexture;
  68857. }
  68858. /**
  68859. * Options for loading OBJ/MTL files
  68860. */
  68861. type MeshLoadOptions = {
  68862. /**
  68863. * Defines if UVs are optimized by default during load.
  68864. */
  68865. OptimizeWithUV: boolean;
  68866. /**
  68867. * Defines custom scaling of UV coordinates of loaded meshes.
  68868. */
  68869. UVScaling: Vector2;
  68870. /**
  68871. * Invert model on y-axis (does a model scaling inversion)
  68872. */
  68873. InvertY: boolean;
  68874. /**
  68875. * Invert Y-Axis of referenced textures on load
  68876. */
  68877. InvertTextureY: boolean;
  68878. /**
  68879. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68880. */
  68881. ImportVertexColors: boolean;
  68882. /**
  68883. * Compute the normals for the model, even if normals are present in the file.
  68884. */
  68885. ComputeNormals: boolean;
  68886. /**
  68887. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68888. */
  68889. SkipMaterials: boolean;
  68890. /**
  68891. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68892. */
  68893. MaterialLoadingFailsSilently: boolean;
  68894. };
  68895. /**
  68896. * OBJ file type loader.
  68897. * This is a babylon scene loader plugin.
  68898. */
  68899. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68900. /**
  68901. * Defines if UVs are optimized by default during load.
  68902. */
  68903. static OPTIMIZE_WITH_UV: boolean;
  68904. /**
  68905. * Invert model on y-axis (does a model scaling inversion)
  68906. */
  68907. static INVERT_Y: boolean;
  68908. /**
  68909. * Invert Y-Axis of referenced textures on load
  68910. */
  68911. static INVERT_TEXTURE_Y: boolean;
  68912. /**
  68913. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68914. */
  68915. static IMPORT_VERTEX_COLORS: boolean;
  68916. /**
  68917. * Compute the normals for the model, even if normals are present in the file.
  68918. */
  68919. static COMPUTE_NORMALS: boolean;
  68920. /**
  68921. * Defines custom scaling of UV coordinates of loaded meshes.
  68922. */
  68923. static UV_SCALING: Vector2;
  68924. /**
  68925. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68926. */
  68927. static SKIP_MATERIALS: boolean;
  68928. /**
  68929. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68930. *
  68931. * Defaults to true for backwards compatibility.
  68932. */
  68933. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68934. /**
  68935. * Defines the name of the plugin.
  68936. */
  68937. name: string;
  68938. /**
  68939. * Defines the extension the plugin is able to load.
  68940. */
  68941. extensions: string;
  68942. /** @hidden */
  68943. obj: RegExp;
  68944. /** @hidden */
  68945. group: RegExp;
  68946. /** @hidden */
  68947. mtllib: RegExp;
  68948. /** @hidden */
  68949. usemtl: RegExp;
  68950. /** @hidden */
  68951. smooth: RegExp;
  68952. /** @hidden */
  68953. vertexPattern: RegExp;
  68954. /** @hidden */
  68955. normalPattern: RegExp;
  68956. /** @hidden */
  68957. uvPattern: RegExp;
  68958. /** @hidden */
  68959. facePattern1: RegExp;
  68960. /** @hidden */
  68961. facePattern2: RegExp;
  68962. /** @hidden */
  68963. facePattern3: RegExp;
  68964. /** @hidden */
  68965. facePattern4: RegExp;
  68966. /** @hidden */
  68967. facePattern5: RegExp;
  68968. private _meshLoadOptions;
  68969. /**
  68970. * Creates loader for .OBJ files
  68971. *
  68972. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68973. */
  68974. constructor(meshLoadOptions?: MeshLoadOptions);
  68975. private static readonly currentMeshLoadOptions;
  68976. /**
  68977. * Calls synchronously the MTL file attached to this obj.
  68978. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68979. * Without this function materials are not displayed in the first frame (but displayed after).
  68980. * In consequence it is impossible to get material information in your HTML file
  68981. *
  68982. * @param url The URL of the MTL file
  68983. * @param rootUrl
  68984. * @param onSuccess Callback function to be called when the MTL file is loaded
  68985. * @private
  68986. */
  68987. private _loadMTL;
  68988. /**
  68989. * Instantiates a OBJ file loader plugin.
  68990. * @returns the created plugin
  68991. */
  68992. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68993. /**
  68994. * If the data string can be loaded directly.
  68995. *
  68996. * @param data string containing the file data
  68997. * @returns if the data can be loaded directly
  68998. */
  68999. canDirectLoad(data: string): boolean;
  69000. /**
  69001. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  69002. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  69003. * @param scene the scene the meshes should be added to
  69004. * @param data the OBJ data to load
  69005. * @param rootUrl root url to load from
  69006. * @param onProgress event that fires when loading progress has occured
  69007. * @param fileName Defines the name of the file to load
  69008. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  69009. */
  69010. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  69011. meshes: AbstractMesh[];
  69012. particleSystems: IParticleSystem[];
  69013. skeletons: Skeleton[];
  69014. animationGroups: AnimationGroup[];
  69015. }>;
  69016. /**
  69017. * Imports all objects from the loaded OBJ data and adds them to the scene
  69018. * @param scene the scene the objects should be added to
  69019. * @param data the OBJ data to load
  69020. * @param rootUrl root url to load from
  69021. * @param onProgress event that fires when loading progress has occured
  69022. * @param fileName Defines the name of the file to load
  69023. * @returns a promise which completes when objects have been loaded to the scene
  69024. */
  69025. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  69026. /**
  69027. * Load into an asset container.
  69028. * @param scene The scene to load into
  69029. * @param data The data to import
  69030. * @param rootUrl The root url for scene and resources
  69031. * @param onProgress The callback when the load progresses
  69032. * @param fileName Defines the name of the file to load
  69033. * @returns The loaded asset container
  69034. */
  69035. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  69036. /**
  69037. * Read the OBJ file and create an Array of meshes.
  69038. * Each mesh contains all information given by the OBJ and the MTL file.
  69039. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  69040. *
  69041. * @param meshesNames
  69042. * @param scene Scene The scene where are displayed the data
  69043. * @param data String The content of the obj file
  69044. * @param rootUrl String The path to the folder
  69045. * @returns Array<AbstractMesh>
  69046. * @private
  69047. */
  69048. private _parseSolid;
  69049. }
  69050. }
  69051. declare module BABYLON {
  69052. /**
  69053. * STL file type loader.
  69054. * This is a babylon scene loader plugin.
  69055. */
  69056. export class STLFileLoader implements ISceneLoaderPlugin {
  69057. /** @hidden */
  69058. solidPattern: RegExp;
  69059. /** @hidden */
  69060. facetsPattern: RegExp;
  69061. /** @hidden */
  69062. normalPattern: RegExp;
  69063. /** @hidden */
  69064. vertexPattern: RegExp;
  69065. /**
  69066. * Defines the name of the plugin.
  69067. */
  69068. name: string;
  69069. /**
  69070. * Defines the extensions the stl loader is able to load.
  69071. * force data to come in as an ArrayBuffer
  69072. * we'll convert to string if it looks like it's an ASCII .stl
  69073. */
  69074. extensions: ISceneLoaderPluginExtensions;
  69075. /**
  69076. * Import meshes into a scene.
  69077. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  69078. * @param scene The scene to import into
  69079. * @param data The data to import
  69080. * @param rootUrl The root url for scene and resources
  69081. * @param meshes The meshes array to import into
  69082. * @param particleSystems The particle systems array to import into
  69083. * @param skeletons The skeletons array to import into
  69084. * @param onError The callback when import fails
  69085. * @returns True if successful or false otherwise
  69086. */
  69087. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  69088. /**
  69089. * Load into a scene.
  69090. * @param scene The scene to load into
  69091. * @param data The data to import
  69092. * @param rootUrl The root url for scene and resources
  69093. * @param onError The callback when import fails
  69094. * @returns true if successful or false otherwise
  69095. */
  69096. load(scene: Scene, data: any, rootUrl: string): boolean;
  69097. /**
  69098. * Load into an asset container.
  69099. * @param scene The scene to load into
  69100. * @param data The data to import
  69101. * @param rootUrl The root url for scene and resources
  69102. * @param onError The callback when import fails
  69103. * @returns The loaded asset container
  69104. */
  69105. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  69106. private _isBinary;
  69107. private _parseBinary;
  69108. private _parseASCII;
  69109. }
  69110. }
  69111. declare module BABYLON {
  69112. /**
  69113. * Class for generating OBJ data from a Babylon scene.
  69114. */
  69115. export class OBJExport {
  69116. /**
  69117. * Exports the geometry of a Mesh array in .OBJ file format (text)
  69118. * @param mesh defines the list of meshes to serialize
  69119. * @param materials defines if materials should be exported
  69120. * @param matlibname defines the name of the associated mtl file
  69121. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  69122. * @returns the OBJ content
  69123. */
  69124. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  69125. /**
  69126. * Exports the material(s) of a mesh in .MTL file format (text)
  69127. * @param mesh defines the mesh to extract the material from
  69128. * @returns the mtl content
  69129. */
  69130. static MTL(mesh: Mesh): string;
  69131. }
  69132. }
  69133. declare module BABYLON {
  69134. /** @hidden */
  69135. export var __IGLTFExporterExtension: number;
  69136. /**
  69137. * Interface for extending the exporter
  69138. * @hidden
  69139. */
  69140. export interface IGLTFExporterExtension {
  69141. /**
  69142. * The name of this extension
  69143. */
  69144. readonly name: string;
  69145. /**
  69146. * Defines whether this extension is enabled
  69147. */
  69148. enabled: boolean;
  69149. /**
  69150. * Defines whether this extension is required
  69151. */
  69152. required: boolean;
  69153. }
  69154. }
  69155. declare module BABYLON.GLTF2.Exporter {
  69156. /** @hidden */
  69157. export var __IGLTFExporterExtensionV2: number;
  69158. /**
  69159. * Interface for a glTF exporter extension
  69160. * @hidden
  69161. */
  69162. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  69163. /**
  69164. * Define this method to modify the default behavior before exporting a texture
  69165. * @param context The context when loading the asset
  69166. * @param babylonTexture The glTF texture info property
  69167. * @param mimeType The mime-type of the generated image
  69168. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  69169. */
  69170. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69171. /**
  69172. * Define this method to modify the default behavior when exporting texture info
  69173. * @param context The context when loading the asset
  69174. * @param meshPrimitive glTF mesh primitive
  69175. * @param babylonSubMesh Babylon submesh
  69176. * @param binaryWriter glTF serializer binary writer instance
  69177. * @returns nullable IMeshPrimitive promise
  69178. */
  69179. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69180. /**
  69181. * Define this method to modify the default behavior when exporting a node
  69182. * @param context The context when exporting the node
  69183. * @param node glTF node
  69184. * @param babylonNode BabylonJS node
  69185. * @returns nullable INode promise
  69186. */
  69187. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69188. /**
  69189. * Called after the exporter state changes to EXPORTING
  69190. */
  69191. onExporting?(): void;
  69192. }
  69193. }
  69194. declare module BABYLON.GLTF2.Exporter {
  69195. /**
  69196. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  69197. * @hidden
  69198. */
  69199. export class _GLTFMaterialExporter {
  69200. /**
  69201. * Represents the dielectric specular values for R, G and B
  69202. */
  69203. private static readonly _DielectricSpecular;
  69204. /**
  69205. * Allows the maximum specular power to be defined for material calculations
  69206. */
  69207. private static readonly _MaxSpecularPower;
  69208. /**
  69209. * Mapping to store textures
  69210. */
  69211. private _textureMap;
  69212. /**
  69213. * Numeric tolerance value
  69214. */
  69215. private static readonly _Epsilon;
  69216. /**
  69217. * Reference to the glTF Exporter
  69218. */
  69219. private _exporter;
  69220. constructor(exporter: _Exporter);
  69221. /**
  69222. * Specifies if two colors are approximately equal in value
  69223. * @param color1 first color to compare to
  69224. * @param color2 second color to compare to
  69225. * @param epsilon threshold value
  69226. */
  69227. private static FuzzyEquals;
  69228. /**
  69229. * Gets the materials from a Babylon scene and converts them to glTF materials
  69230. * @param scene babylonjs scene
  69231. * @param mimeType texture mime type
  69232. * @param images array of images
  69233. * @param textures array of textures
  69234. * @param materials array of materials
  69235. * @param imageData mapping of texture names to base64 textures
  69236. * @param hasTextureCoords specifies if texture coordinates are present on the material
  69237. */
  69238. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69239. /**
  69240. * Makes a copy of the glTF material without the texture parameters
  69241. * @param originalMaterial original glTF material
  69242. * @returns glTF material without texture parameters
  69243. */
  69244. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  69245. /**
  69246. * Specifies if the material has any texture parameters present
  69247. * @param material glTF Material
  69248. * @returns boolean specifying if texture parameters are present
  69249. */
  69250. _hasTexturesPresent(material: IMaterial): boolean;
  69251. /**
  69252. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  69253. * @param babylonStandardMaterial
  69254. * @returns glTF Metallic Roughness Material representation
  69255. */
  69256. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  69257. /**
  69258. * Computes the metallic factor
  69259. * @param diffuse diffused value
  69260. * @param specular specular value
  69261. * @param oneMinusSpecularStrength one minus the specular strength
  69262. * @returns metallic value
  69263. */
  69264. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  69265. /**
  69266. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  69267. * @param glTFMaterial glTF material
  69268. * @param babylonMaterial Babylon material
  69269. */
  69270. private static _SetAlphaMode;
  69271. /**
  69272. * Converts a Babylon Standard Material to a glTF Material
  69273. * @param babylonStandardMaterial BJS Standard Material
  69274. * @param mimeType mime type to use for the textures
  69275. * @param images array of glTF image interfaces
  69276. * @param textures array of glTF texture interfaces
  69277. * @param materials array of glTF material interfaces
  69278. * @param imageData map of image file name to data
  69279. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69280. */
  69281. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69282. /**
  69283. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69284. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  69285. * @param mimeType mime type to use for the textures
  69286. * @param images array of glTF image interfaces
  69287. * @param textures array of glTF texture interfaces
  69288. * @param materials array of glTF material interfaces
  69289. * @param imageData map of image file name to data
  69290. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69291. */
  69292. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69293. /**
  69294. * Converts an image typed array buffer to a base64 image
  69295. * @param buffer typed array buffer
  69296. * @param width width of the image
  69297. * @param height height of the image
  69298. * @param mimeType mimetype of the image
  69299. * @returns base64 image string
  69300. */
  69301. private _createBase64FromCanvasAsync;
  69302. /**
  69303. * Generates a white texture based on the specified width and height
  69304. * @param width width of the texture in pixels
  69305. * @param height height of the texture in pixels
  69306. * @param scene babylonjs scene
  69307. * @returns white texture
  69308. */
  69309. private _createWhiteTexture;
  69310. /**
  69311. * 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
  69312. * @param texture1 first texture to resize
  69313. * @param texture2 second texture to resize
  69314. * @param scene babylonjs scene
  69315. * @returns resized textures or null
  69316. */
  69317. private _resizeTexturesToSameDimensions;
  69318. /**
  69319. * Converts an array of pixels to a Float32Array
  69320. * Throws an error if the pixel format is not supported
  69321. * @param pixels - array buffer containing pixel values
  69322. * @returns Float32 of pixels
  69323. */
  69324. private _convertPixelArrayToFloat32;
  69325. /**
  69326. * Convert Specular Glossiness Textures to Metallic Roughness
  69327. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  69328. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  69329. * @param diffuseTexture texture used to store diffuse information
  69330. * @param specularGlossinessTexture texture used to store specular and glossiness information
  69331. * @param factors specular glossiness material factors
  69332. * @param mimeType the mime type to use for the texture
  69333. * @returns pbr metallic roughness interface or null
  69334. */
  69335. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  69336. /**
  69337. * Converts specular glossiness material properties to metallic roughness
  69338. * @param specularGlossiness interface with specular glossiness material properties
  69339. * @returns interface with metallic roughness material properties
  69340. */
  69341. private _convertSpecularGlossinessToMetallicRoughness;
  69342. /**
  69343. * Calculates the surface reflectance, independent of lighting conditions
  69344. * @param color Color source to calculate brightness from
  69345. * @returns number representing the perceived brightness, or zero if color is undefined
  69346. */
  69347. private _getPerceivedBrightness;
  69348. /**
  69349. * Returns the maximum color component value
  69350. * @param color
  69351. * @returns maximum color component value, or zero if color is null or undefined
  69352. */
  69353. private _getMaxComponent;
  69354. /**
  69355. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  69356. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69357. * @param mimeType mime type to use for the textures
  69358. * @param images array of glTF image interfaces
  69359. * @param textures array of glTF texture interfaces
  69360. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69361. * @param imageData map of image file name to data
  69362. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69363. * @returns glTF PBR Metallic Roughness factors
  69364. */
  69365. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  69366. private _getGLTFTextureSampler;
  69367. private _getGLTFTextureWrapMode;
  69368. private _getGLTFTextureWrapModesSampler;
  69369. /**
  69370. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  69371. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69372. * @param mimeType mime type to use for the textures
  69373. * @param images array of glTF image interfaces
  69374. * @param textures array of glTF texture interfaces
  69375. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  69376. * @param imageData map of image file name to data
  69377. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69378. * @returns glTF PBR Metallic Roughness factors
  69379. */
  69380. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  69381. /**
  69382. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  69383. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  69384. * @param mimeType mime type to use for the textures
  69385. * @param images array of glTF image interfaces
  69386. * @param textures array of glTF texture interfaces
  69387. * @param materials array of glTF material interfaces
  69388. * @param imageData map of image file name to data
  69389. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  69390. */
  69391. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  69392. private setMetallicRoughnessPbrMaterial;
  69393. private getPixelsFromTexture;
  69394. /**
  69395. * Extracts a texture from a Babylon texture into file data and glTF data
  69396. * @param babylonTexture Babylon texture to extract
  69397. * @param mimeType Mime Type of the babylonTexture
  69398. * @return glTF texture info, or null if the texture format is not supported
  69399. */
  69400. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69401. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  69402. /**
  69403. * Builds a texture from base64 string
  69404. * @param base64Texture base64 texture string
  69405. * @param baseTextureName Name to use for the texture
  69406. * @param mimeType image mime type for the texture
  69407. * @param images array of images
  69408. * @param textures array of textures
  69409. * @param imageData map of image data
  69410. * @returns glTF texture info, or null if the texture format is not supported
  69411. */
  69412. private _getTextureInfoFromBase64;
  69413. }
  69414. }
  69415. declare module BABYLON {
  69416. /**
  69417. * Class for holding and downloading glTF file data
  69418. */
  69419. export class GLTFData {
  69420. /**
  69421. * Object which contains the file name as the key and its data as the value
  69422. */
  69423. glTFFiles: {
  69424. [fileName: string]: string | Blob;
  69425. };
  69426. /**
  69427. * Initializes the glTF file object
  69428. */
  69429. constructor();
  69430. /**
  69431. * Downloads the glTF data as files based on their names and data
  69432. */
  69433. downloadFiles(): void;
  69434. }
  69435. }
  69436. declare module BABYLON {
  69437. /**
  69438. * Holds a collection of exporter options and parameters
  69439. */
  69440. export interface IExportOptions {
  69441. /**
  69442. * Function which indicates whether a babylon node should be exported or not
  69443. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  69444. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  69445. */
  69446. shouldExportNode?(node: Node): boolean;
  69447. /**
  69448. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  69449. * @param metadata source metadata to read from
  69450. * @returns the data to store to glTF node extras
  69451. */
  69452. metadataSelector?(metadata: any): any;
  69453. /**
  69454. * The sample rate to bake animation curves
  69455. */
  69456. animationSampleRate?: number;
  69457. /**
  69458. * Begin serialization without waiting for the scene to be ready
  69459. */
  69460. exportWithoutWaitingForScene?: boolean;
  69461. }
  69462. /**
  69463. * Class for generating glTF data from a Babylon scene.
  69464. */
  69465. export class GLTF2Export {
  69466. /**
  69467. * Exports the geometry of the scene to .gltf file format asynchronously
  69468. * @param scene Babylon scene with scene hierarchy information
  69469. * @param filePrefix File prefix to use when generating the glTF file
  69470. * @param options Exporter options
  69471. * @returns Returns an object with a .gltf file and associates texture names
  69472. * as keys and their data and paths as values
  69473. */
  69474. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69475. private static _PreExportAsync;
  69476. private static _PostExportAsync;
  69477. /**
  69478. * Exports the geometry of the scene to .glb file format asychronously
  69479. * @param scene Babylon scene with scene hierarchy information
  69480. * @param filePrefix File prefix to use when generating glb file
  69481. * @param options Exporter options
  69482. * @returns Returns an object with a .glb filename as key and data as value
  69483. */
  69484. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  69485. }
  69486. }
  69487. declare module BABYLON.GLTF2.Exporter {
  69488. /**
  69489. * @hidden
  69490. */
  69491. export class _GLTFUtilities {
  69492. /**
  69493. * Creates a buffer view based on the supplied arguments
  69494. * @param bufferIndex index value of the specified buffer
  69495. * @param byteOffset byte offset value
  69496. * @param byteLength byte length of the bufferView
  69497. * @param byteStride byte distance between conequential elements
  69498. * @param name name of the buffer view
  69499. * @returns bufferView for glTF
  69500. */
  69501. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  69502. /**
  69503. * Creates an accessor based on the supplied arguments
  69504. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  69505. * @param name The name of the accessor
  69506. * @param type The type of the accessor
  69507. * @param componentType The datatype of components in the attribute
  69508. * @param count The number of attributes referenced by this accessor
  69509. * @param byteOffset The offset relative to the start of the bufferView in bytes
  69510. * @param min Minimum value of each component in this attribute
  69511. * @param max Maximum value of each component in this attribute
  69512. * @returns accessor for glTF
  69513. */
  69514. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  69515. /**
  69516. * Calculates the minimum and maximum values of an array of position floats
  69517. * @param positions Positions array of a mesh
  69518. * @param vertexStart Starting vertex offset to calculate min and max values
  69519. * @param vertexCount Number of vertices to check for min and max values
  69520. * @returns min number array and max number array
  69521. */
  69522. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  69523. min: number[];
  69524. max: number[];
  69525. };
  69526. /**
  69527. * Converts a new right-handed Vector3
  69528. * @param vector vector3 array
  69529. * @returns right-handed Vector3
  69530. */
  69531. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  69532. /**
  69533. * Converts a Vector3 to right-handed
  69534. * @param vector Vector3 to convert to right-handed
  69535. */
  69536. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  69537. /**
  69538. * Converts a three element number array to right-handed
  69539. * @param vector number array to convert to right-handed
  69540. */
  69541. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  69542. /**
  69543. * Converts a new right-handed Vector3
  69544. * @param vector vector3 array
  69545. * @returns right-handed Vector3
  69546. */
  69547. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  69548. /**
  69549. * Converts a Vector3 to right-handed
  69550. * @param vector Vector3 to convert to right-handed
  69551. */
  69552. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  69553. /**
  69554. * Converts a three element number array to right-handed
  69555. * @param vector number array to convert to right-handed
  69556. */
  69557. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  69558. /**
  69559. * Converts a Vector4 to right-handed
  69560. * @param vector Vector4 to convert to right-handed
  69561. */
  69562. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  69563. /**
  69564. * Converts a Vector4 to right-handed
  69565. * @param vector Vector4 to convert to right-handed
  69566. */
  69567. static _GetRightHandedArray4FromRef(vector: number[]): void;
  69568. /**
  69569. * Converts a Quaternion to right-handed
  69570. * @param quaternion Source quaternion to convert to right-handed
  69571. */
  69572. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  69573. /**
  69574. * Converts a Quaternion to right-handed
  69575. * @param quaternion Source quaternion to convert to right-handed
  69576. */
  69577. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  69578. static _NormalizeTangentFromRef(tangent: Vector4): void;
  69579. }
  69580. }
  69581. declare module BABYLON.GLTF2.Exporter {
  69582. /**
  69583. * Converts Babylon Scene into glTF 2.0.
  69584. * @hidden
  69585. */
  69586. export class _Exporter {
  69587. /**
  69588. * Stores the glTF to export
  69589. */
  69590. _glTF: IGLTF;
  69591. /**
  69592. * Stores all generated buffer views, which represents views into the main glTF buffer data
  69593. */
  69594. _bufferViews: IBufferView[];
  69595. /**
  69596. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  69597. */
  69598. _accessors: IAccessor[];
  69599. /**
  69600. * Stores all the generated nodes, which contains transform and/or mesh information per node
  69601. */
  69602. private _nodes;
  69603. /**
  69604. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  69605. */
  69606. private _scenes;
  69607. /**
  69608. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  69609. */
  69610. private _meshes;
  69611. /**
  69612. * Stores all the generated material information, which represents the appearance of each primitive
  69613. */
  69614. _materials: IMaterial[];
  69615. _materialMap: {
  69616. [materialID: number]: number;
  69617. };
  69618. /**
  69619. * Stores all the generated texture information, which is referenced by glTF materials
  69620. */
  69621. _textures: ITexture[];
  69622. /**
  69623. * Stores all the generated image information, which is referenced by glTF textures
  69624. */
  69625. _images: IImage[];
  69626. /**
  69627. * Stores all the texture samplers
  69628. */
  69629. _samplers: ISampler[];
  69630. /**
  69631. * Stores all the generated animation samplers, which is referenced by glTF animations
  69632. */
  69633. /**
  69634. * Stores the animations for glTF models
  69635. */
  69636. private _animations;
  69637. /**
  69638. * Stores the total amount of bytes stored in the glTF buffer
  69639. */
  69640. private _totalByteLength;
  69641. /**
  69642. * Stores a reference to the Babylon scene containing the source geometry and material information
  69643. */
  69644. _babylonScene: Scene;
  69645. /**
  69646. * Stores a map of the image data, where the key is the file name and the value
  69647. * is the image data
  69648. */
  69649. _imageData: {
  69650. [fileName: string]: {
  69651. data: Uint8Array;
  69652. mimeType: ImageMimeType;
  69653. };
  69654. };
  69655. /**
  69656. * Stores a map of the unique id of a node to its index in the node array
  69657. */
  69658. private _nodeMap;
  69659. /**
  69660. * Specifies if the Babylon scene should be converted to right-handed on export
  69661. */
  69662. _convertToRightHandedSystem: boolean;
  69663. /**
  69664. * Baked animation sample rate
  69665. */
  69666. private _animationSampleRate;
  69667. private _options;
  69668. private _localEngine;
  69669. _glTFMaterialExporter: _GLTFMaterialExporter;
  69670. private _extensions;
  69671. private static _ExtensionNames;
  69672. private static _ExtensionFactories;
  69673. private _applyExtensions;
  69674. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  69675. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  69676. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69677. private _forEachExtensions;
  69678. private _extensionsOnExporting;
  69679. /**
  69680. * Load glTF serializer extensions
  69681. */
  69682. private _loadExtensions;
  69683. /**
  69684. * Creates a glTF Exporter instance, which can accept optional exporter options
  69685. * @param babylonScene Babylon scene object
  69686. * @param options Options to modify the behavior of the exporter
  69687. */
  69688. constructor(babylonScene: Scene, options?: IExportOptions);
  69689. /**
  69690. * Registers a glTF exporter extension
  69691. * @param name Name of the extension to export
  69692. * @param factory The factory function that creates the exporter extension
  69693. */
  69694. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  69695. /**
  69696. * Un-registers an exporter extension
  69697. * @param name The name fo the exporter extension
  69698. * @returns A boolean indicating whether the extension has been un-registered
  69699. */
  69700. static UnregisterExtension(name: string): boolean;
  69701. /**
  69702. * Lazy load a local engine with premultiplied alpha set to false
  69703. */
  69704. _getLocalEngine(): Engine;
  69705. private reorderIndicesBasedOnPrimitiveMode;
  69706. /**
  69707. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69708. * clock-wise during export to glTF
  69709. * @param submesh BabylonJS submesh
  69710. * @param primitiveMode Primitive mode of the mesh
  69711. * @param sideOrientation the winding order of the submesh
  69712. * @param vertexBufferKind The type of vertex attribute
  69713. * @param meshAttributeArray The vertex attribute data
  69714. * @param byteOffset The offset to the binary data
  69715. * @param binaryWriter The binary data for the glTF file
  69716. */
  69717. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69718. /**
  69719. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69720. * clock-wise during export to glTF
  69721. * @param submesh BabylonJS submesh
  69722. * @param primitiveMode Primitive mode of the mesh
  69723. * @param sideOrientation the winding order of the submesh
  69724. * @param vertexBufferKind The type of vertex attribute
  69725. * @param meshAttributeArray The vertex attribute data
  69726. * @param byteOffset The offset to the binary data
  69727. * @param binaryWriter The binary data for the glTF file
  69728. */
  69729. private reorderTriangleFillMode;
  69730. /**
  69731. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69732. * clock-wise during export to glTF
  69733. * @param submesh BabylonJS submesh
  69734. * @param primitiveMode Primitive mode of the mesh
  69735. * @param sideOrientation the winding order of the submesh
  69736. * @param vertexBufferKind The type of vertex attribute
  69737. * @param meshAttributeArray The vertex attribute data
  69738. * @param byteOffset The offset to the binary data
  69739. * @param binaryWriter The binary data for the glTF file
  69740. */
  69741. private reorderTriangleStripDrawMode;
  69742. /**
  69743. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69744. * clock-wise during export to glTF
  69745. * @param submesh BabylonJS submesh
  69746. * @param primitiveMode Primitive mode of the mesh
  69747. * @param sideOrientation the winding order of the submesh
  69748. * @param vertexBufferKind The type of vertex attribute
  69749. * @param meshAttributeArray The vertex attribute data
  69750. * @param byteOffset The offset to the binary data
  69751. * @param binaryWriter The binary data for the glTF file
  69752. */
  69753. private reorderTriangleFanMode;
  69754. /**
  69755. * Writes the vertex attribute data to binary
  69756. * @param vertices The vertices to write to the binary writer
  69757. * @param byteOffset The offset into the binary writer to overwrite binary data
  69758. * @param vertexAttributeKind The vertex attribute type
  69759. * @param meshAttributeArray The vertex attribute data
  69760. * @param binaryWriter The writer containing the binary data
  69761. */
  69762. private writeVertexAttributeData;
  69763. /**
  69764. * Writes mesh attribute data to a data buffer
  69765. * Returns the bytelength of the data
  69766. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69767. * @param meshAttributeArray Array containing the attribute data
  69768. * @param binaryWriter The buffer to write the binary data to
  69769. * @param indices Used to specify the order of the vertex data
  69770. */
  69771. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69772. /**
  69773. * Generates glTF json data
  69774. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69775. * @param glTFPrefix Text to use when prefixing a glTF file
  69776. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69777. * @returns json data as string
  69778. */
  69779. private generateJSON;
  69780. /**
  69781. * Generates data for .gltf and .bin files based on the glTF prefix string
  69782. * @param glTFPrefix Text to use when prefixing a glTF file
  69783. * @returns GLTFData with glTF file data
  69784. */
  69785. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69786. /**
  69787. * Creates a binary buffer for glTF
  69788. * @returns array buffer for binary data
  69789. */
  69790. private _generateBinaryAsync;
  69791. /**
  69792. * Pads the number to a multiple of 4
  69793. * @param num number to pad
  69794. * @returns padded number
  69795. */
  69796. private _getPadding;
  69797. /**
  69798. * Generates a glb file from the json and binary data
  69799. * Returns an object with the glb file name as the key and data as the value
  69800. * @param glTFPrefix
  69801. * @returns object with glb filename as key and data as value
  69802. */
  69803. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69804. /**
  69805. * Sets the TRS for each node
  69806. * @param node glTF Node for storing the transformation data
  69807. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69808. */
  69809. private setNodeTransformation;
  69810. private getVertexBufferFromMesh;
  69811. /**
  69812. * Creates a bufferview based on the vertices type for the Babylon mesh
  69813. * @param kind Indicates the type of vertices data
  69814. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69815. * @param binaryWriter The buffer to write the bufferview data to
  69816. */
  69817. private createBufferViewKind;
  69818. /**
  69819. * The primitive mode of the Babylon mesh
  69820. * @param babylonMesh The BabylonJS mesh
  69821. */
  69822. private getMeshPrimitiveMode;
  69823. /**
  69824. * Sets the primitive mode of the glTF mesh primitive
  69825. * @param meshPrimitive glTF mesh primitive
  69826. * @param primitiveMode The primitive mode
  69827. */
  69828. private setPrimitiveMode;
  69829. /**
  69830. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69831. * @param meshPrimitive glTF mesh primitive
  69832. * @param attributeKind vertex attribute
  69833. * @returns boolean specifying if uv coordinates are present
  69834. */
  69835. private setAttributeKind;
  69836. /**
  69837. * Sets data for the primitive attributes of each submesh
  69838. * @param mesh glTF Mesh object to store the primitive attribute information
  69839. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69840. * @param binaryWriter Buffer to write the attribute data to
  69841. */
  69842. private setPrimitiveAttributesAsync;
  69843. /**
  69844. * Creates a glTF scene based on the array of meshes
  69845. * Returns the the total byte offset
  69846. * @param babylonScene Babylon scene to get the mesh data from
  69847. * @param binaryWriter Buffer to write binary data to
  69848. */
  69849. private createSceneAsync;
  69850. /**
  69851. * Creates a mapping of Node unique id to node index and handles animations
  69852. * @param babylonScene Babylon Scene
  69853. * @param nodes Babylon transform nodes
  69854. * @param binaryWriter Buffer to write binary data to
  69855. * @returns Node mapping of unique id to index
  69856. */
  69857. private createNodeMapAndAnimationsAsync;
  69858. /**
  69859. * Creates a glTF node from a Babylon mesh
  69860. * @param babylonMesh Source Babylon mesh
  69861. * @param binaryWriter Buffer for storing geometry data
  69862. * @returns glTF node
  69863. */
  69864. private createNodeAsync;
  69865. }
  69866. /**
  69867. * @hidden
  69868. *
  69869. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69870. */
  69871. export class _BinaryWriter {
  69872. /**
  69873. * Array buffer which stores all binary data
  69874. */
  69875. private _arrayBuffer;
  69876. /**
  69877. * View of the array buffer
  69878. */
  69879. private _dataView;
  69880. /**
  69881. * byte offset of data in array buffer
  69882. */
  69883. private _byteOffset;
  69884. /**
  69885. * Initialize binary writer with an initial byte length
  69886. * @param byteLength Initial byte length of the array buffer
  69887. */
  69888. constructor(byteLength: number);
  69889. /**
  69890. * Resize the array buffer to the specified byte length
  69891. * @param byteLength
  69892. */
  69893. private resizeBuffer;
  69894. /**
  69895. * Get an array buffer with the length of the byte offset
  69896. * @returns ArrayBuffer resized to the byte offset
  69897. */
  69898. getArrayBuffer(): ArrayBuffer;
  69899. /**
  69900. * Get the byte offset of the array buffer
  69901. * @returns byte offset
  69902. */
  69903. getByteOffset(): number;
  69904. /**
  69905. * Stores an UInt8 in the array buffer
  69906. * @param entry
  69907. * @param byteOffset If defined, specifies where to set the value as an offset.
  69908. */
  69909. setUInt8(entry: number, byteOffset?: number): void;
  69910. /**
  69911. * Gets an UInt32 in the array buffer
  69912. * @param entry
  69913. * @param byteOffset If defined, specifies where to set the value as an offset.
  69914. */
  69915. getUInt32(byteOffset: number): number;
  69916. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69917. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69918. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69919. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69920. /**
  69921. * Stores a Float32 in the array buffer
  69922. * @param entry
  69923. */
  69924. setFloat32(entry: number, byteOffset?: number): void;
  69925. /**
  69926. * Stores an UInt32 in the array buffer
  69927. * @param entry
  69928. * @param byteOffset If defined, specifies where to set the value as an offset.
  69929. */
  69930. setUInt32(entry: number, byteOffset?: number): void;
  69931. }
  69932. }
  69933. declare module BABYLON.GLTF2.Exporter {
  69934. /**
  69935. * @hidden
  69936. * Interface to store animation data.
  69937. */
  69938. export interface _IAnimationData {
  69939. /**
  69940. * Keyframe data.
  69941. */
  69942. inputs: number[];
  69943. /**
  69944. * Value data.
  69945. */
  69946. outputs: number[][];
  69947. /**
  69948. * Animation interpolation data.
  69949. */
  69950. samplerInterpolation: AnimationSamplerInterpolation;
  69951. /**
  69952. * Minimum keyframe value.
  69953. */
  69954. inputsMin: number;
  69955. /**
  69956. * Maximum keyframe value.
  69957. */
  69958. inputsMax: number;
  69959. }
  69960. /**
  69961. * @hidden
  69962. */
  69963. export interface _IAnimationInfo {
  69964. /**
  69965. * The target channel for the animation
  69966. */
  69967. animationChannelTargetPath: AnimationChannelTargetPath;
  69968. /**
  69969. * The glTF accessor type for the data.
  69970. */
  69971. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69972. /**
  69973. * Specifies if quaternions should be used.
  69974. */
  69975. useQuaternion: boolean;
  69976. }
  69977. /**
  69978. * @hidden
  69979. * Utility class for generating glTF animation data from BabylonJS.
  69980. */
  69981. export class _GLTFAnimation {
  69982. /**
  69983. * @ignore
  69984. *
  69985. * Creates glTF channel animation from BabylonJS animation.
  69986. * @param babylonTransformNode - BabylonJS mesh.
  69987. * @param animation - animation.
  69988. * @param animationChannelTargetPath - The target animation channel.
  69989. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69990. * @param useQuaternion - Specifies if quaternions are used.
  69991. * @returns nullable IAnimationData
  69992. */
  69993. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69994. private static _DeduceAnimationInfo;
  69995. /**
  69996. * @ignore
  69997. * Create node animations from the transform node animations
  69998. * @param babylonNode
  69999. * @param runtimeGLTFAnimation
  70000. * @param idleGLTFAnimations
  70001. * @param nodeMap
  70002. * @param nodes
  70003. * @param binaryWriter
  70004. * @param bufferViews
  70005. * @param accessors
  70006. * @param convertToRightHandedSystem
  70007. */
  70008. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  70009. [key: number]: number;
  70010. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70011. /**
  70012. * @ignore
  70013. * Create node animations from the animation groups
  70014. * @param babylonScene
  70015. * @param glTFAnimations
  70016. * @param nodeMap
  70017. * @param nodes
  70018. * @param binaryWriter
  70019. * @param bufferViews
  70020. * @param accessors
  70021. * @param convertToRightHandedSystem
  70022. */
  70023. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  70024. [key: number]: number;
  70025. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  70026. private static AddAnimation;
  70027. /**
  70028. * Create a baked animation
  70029. * @param babylonTransformNode BabylonJS mesh
  70030. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  70031. * @param animationChannelTargetPath animation target channel
  70032. * @param minFrame minimum animation frame
  70033. * @param maxFrame maximum animation frame
  70034. * @param fps frames per second of the animation
  70035. * @param inputs input key frames of the animation
  70036. * @param outputs output key frame data of the animation
  70037. * @param convertToRightHandedSystem converts the values to right-handed
  70038. * @param useQuaternion specifies if quaternions should be used
  70039. */
  70040. private static _CreateBakedAnimation;
  70041. private static _ConvertFactorToVector3OrQuaternion;
  70042. private static _SetInterpolatedValue;
  70043. /**
  70044. * Creates linear animation from the animation key frames
  70045. * @param babylonTransformNode BabylonJS mesh
  70046. * @param animation BabylonJS animation
  70047. * @param animationChannelTargetPath The target animation channel
  70048. * @param frameDelta The difference between the last and first frame of the animation
  70049. * @param inputs Array to store the key frame times
  70050. * @param outputs Array to store the key frame data
  70051. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70052. * @param useQuaternion Specifies if quaternions are used in the animation
  70053. */
  70054. private static _CreateLinearOrStepAnimation;
  70055. /**
  70056. * Creates cubic spline animation from the animation key frames
  70057. * @param babylonTransformNode BabylonJS mesh
  70058. * @param animation BabylonJS animation
  70059. * @param animationChannelTargetPath The target animation channel
  70060. * @param frameDelta The difference between the last and first frame of the animation
  70061. * @param inputs Array to store the key frame times
  70062. * @param outputs Array to store the key frame data
  70063. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  70064. * @param useQuaternion Specifies if quaternions are used in the animation
  70065. */
  70066. private static _CreateCubicSplineAnimation;
  70067. private static _GetBasePositionRotationOrScale;
  70068. /**
  70069. * Adds a key frame value
  70070. * @param keyFrame
  70071. * @param animation
  70072. * @param outputs
  70073. * @param animationChannelTargetPath
  70074. * @param basePositionRotationOrScale
  70075. * @param convertToRightHandedSystem
  70076. * @param useQuaternion
  70077. */
  70078. private static _AddKeyframeValue;
  70079. /**
  70080. * Determine the interpolation based on the key frames
  70081. * @param keyFrames
  70082. * @param animationChannelTargetPath
  70083. * @param useQuaternion
  70084. */
  70085. private static _DeduceInterpolation;
  70086. /**
  70087. * Adds an input tangent or output tangent to the output data
  70088. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  70089. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  70090. * @param outputs The animation data by keyframe
  70091. * @param animationChannelTargetPath The target animation channel
  70092. * @param interpolation The interpolation type
  70093. * @param keyFrame The key frame with the animation data
  70094. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  70095. * @param useQuaternion Specifies if quaternions are used
  70096. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  70097. */
  70098. private static AddSplineTangent;
  70099. /**
  70100. * Get the minimum and maximum key frames' frame values
  70101. * @param keyFrames animation key frames
  70102. * @returns the minimum and maximum key frame value
  70103. */
  70104. private static calculateMinMaxKeyFrames;
  70105. }
  70106. }
  70107. declare module BABYLON.GLTF2.Exporter {
  70108. /** @hidden */
  70109. export var textureTransformPixelShader: {
  70110. name: string;
  70111. shader: string;
  70112. };
  70113. }
  70114. declare module BABYLON.GLTF2.Exporter.Extensions {
  70115. /**
  70116. * @hidden
  70117. */
  70118. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  70119. /** Name of this extension */
  70120. readonly name: string;
  70121. /** Defines whether this extension is enabled */
  70122. enabled: boolean;
  70123. /** Defines whether this extension is required */
  70124. required: boolean;
  70125. /** Reference to the glTF exporter */
  70126. private _exporter;
  70127. constructor(exporter: _Exporter);
  70128. dispose(): void;
  70129. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  70130. /**
  70131. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  70132. * @param babylonTexture
  70133. * @param offset
  70134. * @param rotation
  70135. * @param scale
  70136. * @param scene
  70137. */
  70138. private _textureTransformTextureAsync;
  70139. }
  70140. }
  70141. declare module BABYLON.GLTF2.Exporter.Extensions {
  70142. /**
  70143. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  70144. */
  70145. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  70146. /** The name of this extension. */
  70147. readonly name: string;
  70148. /** Defines whether this extension is enabled. */
  70149. enabled: boolean;
  70150. /** Defines whether this extension is required */
  70151. required: boolean;
  70152. /** Reference to the glTF exporter */
  70153. private _exporter;
  70154. private _lights;
  70155. /** @hidden */
  70156. constructor(exporter: _Exporter);
  70157. /** @hidden */
  70158. dispose(): void;
  70159. /** @hidden */
  70160. onExporting(): void;
  70161. /**
  70162. * Define this method to modify the default behavior when exporting a node
  70163. * @param context The context when exporting the node
  70164. * @param node glTF node
  70165. * @param babylonNode BabylonJS node
  70166. * @returns nullable INode promise
  70167. */
  70168. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  70169. }
  70170. }
  70171. declare module BABYLON {
  70172. /**
  70173. * Class for generating STL data from a Babylon scene.
  70174. */
  70175. export class STLExport {
  70176. /**
  70177. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  70178. * @param meshes list defines the mesh to serialize
  70179. * @param download triggers the automatic download of the file.
  70180. * @param fileName changes the downloads fileName.
  70181. * @param binary changes the STL to a binary type.
  70182. * @param isLittleEndian toggle for binary type exporter.
  70183. * @returns the STL as UTF8 string
  70184. */
  70185. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  70186. }
  70187. }
  70188. declare module "babylonjs-gltf2interface" {
  70189. export = BABYLON.GLTF2;
  70190. }
  70191. /**
  70192. * Module for glTF 2.0 Interface
  70193. */
  70194. declare module BABYLON.GLTF2 {
  70195. /**
  70196. * The datatype of the components in the attribute
  70197. */
  70198. const enum AccessorComponentType {
  70199. /**
  70200. * Byte
  70201. */
  70202. BYTE = 5120,
  70203. /**
  70204. * Unsigned Byte
  70205. */
  70206. UNSIGNED_BYTE = 5121,
  70207. /**
  70208. * Short
  70209. */
  70210. SHORT = 5122,
  70211. /**
  70212. * Unsigned Short
  70213. */
  70214. UNSIGNED_SHORT = 5123,
  70215. /**
  70216. * Unsigned Int
  70217. */
  70218. UNSIGNED_INT = 5125,
  70219. /**
  70220. * Float
  70221. */
  70222. FLOAT = 5126,
  70223. }
  70224. /**
  70225. * Specifies if the attirbute is a scalar, vector, or matrix
  70226. */
  70227. const enum AccessorType {
  70228. /**
  70229. * Scalar
  70230. */
  70231. SCALAR = "SCALAR",
  70232. /**
  70233. * Vector2
  70234. */
  70235. VEC2 = "VEC2",
  70236. /**
  70237. * Vector3
  70238. */
  70239. VEC3 = "VEC3",
  70240. /**
  70241. * Vector4
  70242. */
  70243. VEC4 = "VEC4",
  70244. /**
  70245. * Matrix2x2
  70246. */
  70247. MAT2 = "MAT2",
  70248. /**
  70249. * Matrix3x3
  70250. */
  70251. MAT3 = "MAT3",
  70252. /**
  70253. * Matrix4x4
  70254. */
  70255. MAT4 = "MAT4",
  70256. }
  70257. /**
  70258. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70259. */
  70260. const enum AnimationChannelTargetPath {
  70261. /**
  70262. * Translation
  70263. */
  70264. TRANSLATION = "translation",
  70265. /**
  70266. * Rotation
  70267. */
  70268. ROTATION = "rotation",
  70269. /**
  70270. * Scale
  70271. */
  70272. SCALE = "scale",
  70273. /**
  70274. * Weights
  70275. */
  70276. WEIGHTS = "weights",
  70277. }
  70278. /**
  70279. * Interpolation algorithm
  70280. */
  70281. const enum AnimationSamplerInterpolation {
  70282. /**
  70283. * The animated values are linearly interpolated between keyframes
  70284. */
  70285. LINEAR = "LINEAR",
  70286. /**
  70287. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  70288. */
  70289. STEP = "STEP",
  70290. /**
  70291. * The animation's interpolation is computed using a cubic spline with specified tangents
  70292. */
  70293. CUBICSPLINE = "CUBICSPLINE",
  70294. }
  70295. /**
  70296. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70297. */
  70298. const enum CameraType {
  70299. /**
  70300. * A perspective camera containing properties to create a perspective projection matrix
  70301. */
  70302. PERSPECTIVE = "perspective",
  70303. /**
  70304. * An orthographic camera containing properties to create an orthographic projection matrix
  70305. */
  70306. ORTHOGRAPHIC = "orthographic",
  70307. }
  70308. /**
  70309. * The mime-type of the image
  70310. */
  70311. const enum ImageMimeType {
  70312. /**
  70313. * JPEG Mime-type
  70314. */
  70315. JPEG = "image/jpeg",
  70316. /**
  70317. * PNG Mime-type
  70318. */
  70319. PNG = "image/png",
  70320. }
  70321. /**
  70322. * The alpha rendering mode of the material
  70323. */
  70324. const enum MaterialAlphaMode {
  70325. /**
  70326. * The alpha value is ignored and the rendered output is fully opaque
  70327. */
  70328. OPAQUE = "OPAQUE",
  70329. /**
  70330. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  70331. */
  70332. MASK = "MASK",
  70333. /**
  70334. * 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)
  70335. */
  70336. BLEND = "BLEND",
  70337. }
  70338. /**
  70339. * The type of the primitives to render
  70340. */
  70341. const enum MeshPrimitiveMode {
  70342. /**
  70343. * Points
  70344. */
  70345. POINTS = 0,
  70346. /**
  70347. * Lines
  70348. */
  70349. LINES = 1,
  70350. /**
  70351. * Line Loop
  70352. */
  70353. LINE_LOOP = 2,
  70354. /**
  70355. * Line Strip
  70356. */
  70357. LINE_STRIP = 3,
  70358. /**
  70359. * Triangles
  70360. */
  70361. TRIANGLES = 4,
  70362. /**
  70363. * Triangle Strip
  70364. */
  70365. TRIANGLE_STRIP = 5,
  70366. /**
  70367. * Triangle Fan
  70368. */
  70369. TRIANGLE_FAN = 6,
  70370. }
  70371. /**
  70372. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70373. */
  70374. const enum TextureMagFilter {
  70375. /**
  70376. * Nearest
  70377. */
  70378. NEAREST = 9728,
  70379. /**
  70380. * Linear
  70381. */
  70382. LINEAR = 9729,
  70383. }
  70384. /**
  70385. * Minification filter. All valid values correspond to WebGL enums
  70386. */
  70387. const enum TextureMinFilter {
  70388. /**
  70389. * Nearest
  70390. */
  70391. NEAREST = 9728,
  70392. /**
  70393. * Linear
  70394. */
  70395. LINEAR = 9729,
  70396. /**
  70397. * Nearest Mip-Map Nearest
  70398. */
  70399. NEAREST_MIPMAP_NEAREST = 9984,
  70400. /**
  70401. * Linear Mipmap Nearest
  70402. */
  70403. LINEAR_MIPMAP_NEAREST = 9985,
  70404. /**
  70405. * Nearest Mipmap Linear
  70406. */
  70407. NEAREST_MIPMAP_LINEAR = 9986,
  70408. /**
  70409. * Linear Mipmap Linear
  70410. */
  70411. LINEAR_MIPMAP_LINEAR = 9987,
  70412. }
  70413. /**
  70414. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70415. */
  70416. const enum TextureWrapMode {
  70417. /**
  70418. * Clamp to Edge
  70419. */
  70420. CLAMP_TO_EDGE = 33071,
  70421. /**
  70422. * Mirrored Repeat
  70423. */
  70424. MIRRORED_REPEAT = 33648,
  70425. /**
  70426. * Repeat
  70427. */
  70428. REPEAT = 10497,
  70429. }
  70430. /**
  70431. * glTF Property
  70432. */
  70433. interface IProperty {
  70434. /**
  70435. * Dictionary object with extension-specific objects
  70436. */
  70437. extensions?: {
  70438. [key: string]: any;
  70439. };
  70440. /**
  70441. * Application-Specific data
  70442. */
  70443. extras?: any;
  70444. }
  70445. /**
  70446. * glTF Child of Root Property
  70447. */
  70448. interface IChildRootProperty extends IProperty {
  70449. /**
  70450. * The user-defined name of this object
  70451. */
  70452. name?: string;
  70453. }
  70454. /**
  70455. * Indices of those attributes that deviate from their initialization value
  70456. */
  70457. interface IAccessorSparseIndices extends IProperty {
  70458. /**
  70459. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70460. */
  70461. bufferView: number;
  70462. /**
  70463. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70464. */
  70465. byteOffset?: number;
  70466. /**
  70467. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  70468. */
  70469. componentType: AccessorComponentType;
  70470. }
  70471. /**
  70472. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  70473. */
  70474. interface IAccessorSparseValues extends IProperty {
  70475. /**
  70476. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  70477. */
  70478. bufferView: number;
  70479. /**
  70480. * The offset relative to the start of the bufferView in bytes. Must be aligned
  70481. */
  70482. byteOffset?: number;
  70483. }
  70484. /**
  70485. * Sparse storage of attributes that deviate from their initialization value
  70486. */
  70487. interface IAccessorSparse extends IProperty {
  70488. /**
  70489. * The number of attributes encoded in this sparse accessor
  70490. */
  70491. count: number;
  70492. /**
  70493. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  70494. */
  70495. indices: IAccessorSparseIndices;
  70496. /**
  70497. * 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
  70498. */
  70499. values: IAccessorSparseValues;
  70500. }
  70501. /**
  70502. * 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
  70503. */
  70504. interface IAccessor extends IChildRootProperty {
  70505. /**
  70506. * The index of the bufferview
  70507. */
  70508. bufferView?: number;
  70509. /**
  70510. * The offset relative to the start of the bufferView in bytes
  70511. */
  70512. byteOffset?: number;
  70513. /**
  70514. * The datatype of components in the attribute
  70515. */
  70516. componentType: AccessorComponentType;
  70517. /**
  70518. * Specifies whether integer data values should be normalized
  70519. */
  70520. normalized?: boolean;
  70521. /**
  70522. * The number of attributes referenced by this accessor
  70523. */
  70524. count: number;
  70525. /**
  70526. * Specifies if the attribute is a scalar, vector, or matrix
  70527. */
  70528. type: AccessorType;
  70529. /**
  70530. * Maximum value of each component in this attribute
  70531. */
  70532. max?: number[];
  70533. /**
  70534. * Minimum value of each component in this attribute
  70535. */
  70536. min?: number[];
  70537. /**
  70538. * Sparse storage of attributes that deviate from their initialization value
  70539. */
  70540. sparse?: IAccessorSparse;
  70541. }
  70542. /**
  70543. * Targets an animation's sampler at a node's property
  70544. */
  70545. interface IAnimationChannel extends IProperty {
  70546. /**
  70547. * The index of a sampler in this animation used to compute the value for the target
  70548. */
  70549. sampler: number;
  70550. /**
  70551. * The index of the node and TRS property to target
  70552. */
  70553. target: IAnimationChannelTarget;
  70554. }
  70555. /**
  70556. * The index of the node and TRS property that an animation channel targets
  70557. */
  70558. interface IAnimationChannelTarget extends IProperty {
  70559. /**
  70560. * The index of the node to target
  70561. */
  70562. node: number;
  70563. /**
  70564. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  70565. */
  70566. path: AnimationChannelTargetPath;
  70567. }
  70568. /**
  70569. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70570. */
  70571. interface IAnimationSampler extends IProperty {
  70572. /**
  70573. * The index of an accessor containing keyframe input values, e.g., time
  70574. */
  70575. input: number;
  70576. /**
  70577. * Interpolation algorithm
  70578. */
  70579. interpolation?: AnimationSamplerInterpolation;
  70580. /**
  70581. * The index of an accessor, containing keyframe output values
  70582. */
  70583. output: number;
  70584. }
  70585. /**
  70586. * A keyframe animation
  70587. */
  70588. interface IAnimation extends IChildRootProperty {
  70589. /**
  70590. * An array of channels, each of which targets an animation's sampler at a node's property
  70591. */
  70592. channels: IAnimationChannel[];
  70593. /**
  70594. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  70595. */
  70596. samplers: IAnimationSampler[];
  70597. }
  70598. /**
  70599. * Metadata about the glTF asset
  70600. */
  70601. interface IAsset extends IChildRootProperty {
  70602. /**
  70603. * A copyright message suitable for display to credit the content creator
  70604. */
  70605. copyright?: string;
  70606. /**
  70607. * Tool that generated this glTF model. Useful for debugging
  70608. */
  70609. generator?: string;
  70610. /**
  70611. * The glTF version that this asset targets
  70612. */
  70613. version: string;
  70614. /**
  70615. * The minimum glTF version that this asset targets
  70616. */
  70617. minVersion?: string;
  70618. }
  70619. /**
  70620. * A buffer points to binary geometry, animation, or skins
  70621. */
  70622. interface IBuffer extends IChildRootProperty {
  70623. /**
  70624. * 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
  70625. */
  70626. uri?: string;
  70627. /**
  70628. * The length of the buffer in bytes
  70629. */
  70630. byteLength: number;
  70631. }
  70632. /**
  70633. * A view into a buffer generally representing a subset of the buffer
  70634. */
  70635. interface IBufferView extends IChildRootProperty {
  70636. /**
  70637. * The index of the buffer
  70638. */
  70639. buffer: number;
  70640. /**
  70641. * The offset into the buffer in bytes
  70642. */
  70643. byteOffset?: number;
  70644. /**
  70645. * The lenth of the bufferView in bytes
  70646. */
  70647. byteLength: number;
  70648. /**
  70649. * The stride, in bytes
  70650. */
  70651. byteStride?: number;
  70652. }
  70653. /**
  70654. * An orthographic camera containing properties to create an orthographic projection matrix
  70655. */
  70656. interface ICameraOrthographic extends IProperty {
  70657. /**
  70658. * The floating-point horizontal magnification of the view. Must not be zero
  70659. */
  70660. xmag: number;
  70661. /**
  70662. * The floating-point vertical magnification of the view. Must not be zero
  70663. */
  70664. ymag: number;
  70665. /**
  70666. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  70667. */
  70668. zfar: number;
  70669. /**
  70670. * The floating-point distance to the near clipping plane
  70671. */
  70672. znear: number;
  70673. }
  70674. /**
  70675. * A perspective camera containing properties to create a perspective projection matrix
  70676. */
  70677. interface ICameraPerspective extends IProperty {
  70678. /**
  70679. * The floating-point aspect ratio of the field of view
  70680. */
  70681. aspectRatio?: number;
  70682. /**
  70683. * The floating-point vertical field of view in radians
  70684. */
  70685. yfov: number;
  70686. /**
  70687. * The floating-point distance to the far clipping plane
  70688. */
  70689. zfar?: number;
  70690. /**
  70691. * The floating-point distance to the near clipping plane
  70692. */
  70693. znear: number;
  70694. }
  70695. /**
  70696. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  70697. */
  70698. interface ICamera extends IChildRootProperty {
  70699. /**
  70700. * An orthographic camera containing properties to create an orthographic projection matrix
  70701. */
  70702. orthographic?: ICameraOrthographic;
  70703. /**
  70704. * A perspective camera containing properties to create a perspective projection matrix
  70705. */
  70706. perspective?: ICameraPerspective;
  70707. /**
  70708. * Specifies if the camera uses a perspective or orthographic projection
  70709. */
  70710. type: CameraType;
  70711. }
  70712. /**
  70713. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70714. */
  70715. interface IImage extends IChildRootProperty {
  70716. /**
  70717. * 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
  70718. */
  70719. uri?: string;
  70720. /**
  70721. * The image's MIME type
  70722. */
  70723. mimeType?: ImageMimeType;
  70724. /**
  70725. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70726. */
  70727. bufferView?: number;
  70728. }
  70729. /**
  70730. * Material Normal Texture Info
  70731. */
  70732. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70733. /**
  70734. * The scalar multiplier applied to each normal vector of the normal texture
  70735. */
  70736. scale?: number;
  70737. }
  70738. /**
  70739. * Material Occlusion Texture Info
  70740. */
  70741. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70742. /**
  70743. * A scalar multiplier controlling the amount of occlusion applied
  70744. */
  70745. strength?: number;
  70746. }
  70747. /**
  70748. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70749. */
  70750. interface IMaterialPbrMetallicRoughness {
  70751. /**
  70752. * The material's base color factor
  70753. */
  70754. baseColorFactor?: number[];
  70755. /**
  70756. * The base color texture
  70757. */
  70758. baseColorTexture?: ITextureInfo;
  70759. /**
  70760. * The metalness of the material
  70761. */
  70762. metallicFactor?: number;
  70763. /**
  70764. * The roughness of the material
  70765. */
  70766. roughnessFactor?: number;
  70767. /**
  70768. * The metallic-roughness texture
  70769. */
  70770. metallicRoughnessTexture?: ITextureInfo;
  70771. }
  70772. /**
  70773. * The material appearance of a primitive
  70774. */
  70775. interface IMaterial extends IChildRootProperty {
  70776. /**
  70777. * 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
  70778. */
  70779. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70780. /**
  70781. * The normal map texture
  70782. */
  70783. normalTexture?: IMaterialNormalTextureInfo;
  70784. /**
  70785. * The occlusion map texture
  70786. */
  70787. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70788. /**
  70789. * The emissive map texture
  70790. */
  70791. emissiveTexture?: ITextureInfo;
  70792. /**
  70793. * 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
  70794. */
  70795. emissiveFactor?: number[];
  70796. /**
  70797. * The alpha rendering mode of the material
  70798. */
  70799. alphaMode?: MaterialAlphaMode;
  70800. /**
  70801. * The alpha cutoff value of the material
  70802. */
  70803. alphaCutoff?: number;
  70804. /**
  70805. * Specifies whether the material is double sided
  70806. */
  70807. doubleSided?: boolean;
  70808. }
  70809. /**
  70810. * Geometry to be rendered with the given material
  70811. */
  70812. interface IMeshPrimitive extends IProperty {
  70813. /**
  70814. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70815. */
  70816. attributes: {
  70817. [name: string]: number;
  70818. };
  70819. /**
  70820. * The index of the accessor that contains the indices
  70821. */
  70822. indices?: number;
  70823. /**
  70824. * The index of the material to apply to this primitive when rendering
  70825. */
  70826. material?: number;
  70827. /**
  70828. * The type of primitives to render. All valid values correspond to WebGL enums
  70829. */
  70830. mode?: MeshPrimitiveMode;
  70831. /**
  70832. * 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
  70833. */
  70834. targets?: {
  70835. [name: string]: number;
  70836. }[];
  70837. }
  70838. /**
  70839. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70840. */
  70841. interface IMesh extends IChildRootProperty {
  70842. /**
  70843. * An array of primitives, each defining geometry to be rendered with a material
  70844. */
  70845. primitives: IMeshPrimitive[];
  70846. /**
  70847. * Array of weights to be applied to the Morph Targets
  70848. */
  70849. weights?: number[];
  70850. }
  70851. /**
  70852. * A node in the node hierarchy
  70853. */
  70854. interface INode extends IChildRootProperty {
  70855. /**
  70856. * The index of the camera referenced by this node
  70857. */
  70858. camera?: number;
  70859. /**
  70860. * The indices of this node's children
  70861. */
  70862. children?: number[];
  70863. /**
  70864. * The index of the skin referenced by this node
  70865. */
  70866. skin?: number;
  70867. /**
  70868. * A floating-point 4x4 transformation matrix stored in column-major order
  70869. */
  70870. matrix?: number[];
  70871. /**
  70872. * The index of the mesh in this node
  70873. */
  70874. mesh?: number;
  70875. /**
  70876. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70877. */
  70878. rotation?: number[];
  70879. /**
  70880. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70881. */
  70882. scale?: number[];
  70883. /**
  70884. * The node's translation along the x, y, and z axes
  70885. */
  70886. translation?: number[];
  70887. /**
  70888. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70889. */
  70890. weights?: number[];
  70891. }
  70892. /**
  70893. * Texture sampler properties for filtering and wrapping modes
  70894. */
  70895. interface ISampler extends IChildRootProperty {
  70896. /**
  70897. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70898. */
  70899. magFilter?: TextureMagFilter;
  70900. /**
  70901. * Minification filter. All valid values correspond to WebGL enums
  70902. */
  70903. minFilter?: TextureMinFilter;
  70904. /**
  70905. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70906. */
  70907. wrapS?: TextureWrapMode;
  70908. /**
  70909. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70910. */
  70911. wrapT?: TextureWrapMode;
  70912. }
  70913. /**
  70914. * The root nodes of a scene
  70915. */
  70916. interface IScene extends IChildRootProperty {
  70917. /**
  70918. * The indices of each root node
  70919. */
  70920. nodes: number[];
  70921. }
  70922. /**
  70923. * Joints and matrices defining a skin
  70924. */
  70925. interface ISkin extends IChildRootProperty {
  70926. /**
  70927. * 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
  70928. */
  70929. inverseBindMatrices?: number;
  70930. /**
  70931. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70932. */
  70933. skeleton?: number;
  70934. /**
  70935. * 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)
  70936. */
  70937. joints: number[];
  70938. }
  70939. /**
  70940. * A texture and its sampler
  70941. */
  70942. interface ITexture extends IChildRootProperty {
  70943. /**
  70944. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70945. */
  70946. sampler?: number;
  70947. /**
  70948. * The index of the image used by this texture
  70949. */
  70950. source: number;
  70951. }
  70952. /**
  70953. * Reference to a texture
  70954. */
  70955. interface ITextureInfo extends IProperty {
  70956. /**
  70957. * The index of the texture
  70958. */
  70959. index: number;
  70960. /**
  70961. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70962. */
  70963. texCoord?: number;
  70964. }
  70965. /**
  70966. * The root object for a glTF asset
  70967. */
  70968. interface IGLTF extends IProperty {
  70969. /**
  70970. * An array of accessors. An accessor is a typed view into a bufferView
  70971. */
  70972. accessors?: IAccessor[];
  70973. /**
  70974. * An array of keyframe animations
  70975. */
  70976. animations?: IAnimation[];
  70977. /**
  70978. * Metadata about the glTF asset
  70979. */
  70980. asset: IAsset;
  70981. /**
  70982. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70983. */
  70984. buffers?: IBuffer[];
  70985. /**
  70986. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70987. */
  70988. bufferViews?: IBufferView[];
  70989. /**
  70990. * An array of cameras
  70991. */
  70992. cameras?: ICamera[];
  70993. /**
  70994. * Names of glTF extensions used somewhere in this asset
  70995. */
  70996. extensionsUsed?: string[];
  70997. /**
  70998. * Names of glTF extensions required to properly load this asset
  70999. */
  71000. extensionsRequired?: string[];
  71001. /**
  71002. * An array of images. An image defines data used to create a texture
  71003. */
  71004. images?: IImage[];
  71005. /**
  71006. * An array of materials. A material defines the appearance of a primitive
  71007. */
  71008. materials?: IMaterial[];
  71009. /**
  71010. * An array of meshes. A mesh is a set of primitives to be rendered
  71011. */
  71012. meshes?: IMesh[];
  71013. /**
  71014. * An array of nodes
  71015. */
  71016. nodes?: INode[];
  71017. /**
  71018. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  71019. */
  71020. samplers?: ISampler[];
  71021. /**
  71022. * The index of the default scene
  71023. */
  71024. scene?: number;
  71025. /**
  71026. * An array of scenes
  71027. */
  71028. scenes?: IScene[];
  71029. /**
  71030. * An array of skins. A skin is defined by joints and matrices
  71031. */
  71032. skins?: ISkin[];
  71033. /**
  71034. * An array of textures
  71035. */
  71036. textures?: ITexture[];
  71037. }
  71038. /**
  71039. * The glTF validation results
  71040. * @ignore
  71041. */
  71042. interface IGLTFValidationResults {
  71043. info: {
  71044. generator: string;
  71045. hasAnimations: boolean;
  71046. hasDefaultScene: boolean;
  71047. hasMaterials: boolean;
  71048. hasMorphTargets: boolean;
  71049. hasSkins: boolean;
  71050. hasTextures: boolean;
  71051. maxAttributesUsed: number;
  71052. primitivesCount: number
  71053. };
  71054. issues: {
  71055. messages: Array<string>;
  71056. numErrors: number;
  71057. numHints: number;
  71058. numInfos: number;
  71059. numWarnings: number;
  71060. truncated: boolean
  71061. };
  71062. mimeType: string;
  71063. uri: string;
  71064. validatedAt: string;
  71065. validatorVersion: string;
  71066. }
  71067. /**
  71068. * The glTF validation options
  71069. */
  71070. interface IGLTFValidationOptions {
  71071. /** Uri to use */
  71072. uri?: string;
  71073. /** Function used to load external resources */
  71074. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  71075. /** Boolean indicating that we need to validate accessor data */
  71076. validateAccessorData?: boolean;
  71077. /** max number of issues allowed */
  71078. maxIssues?: number;
  71079. /** Ignored issues */
  71080. ignoredIssues?: Array<string>;
  71081. /** Value to override severy settings */
  71082. severityOverrides?: Object;
  71083. }
  71084. /**
  71085. * The glTF validator object
  71086. * @ignore
  71087. */
  71088. interface IGLTFValidator {
  71089. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71090. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  71091. }
  71092. }
  71093. declare module BABYLON {
  71094. /** @hidden */
  71095. export var cellPixelShader: {
  71096. name: string;
  71097. shader: string;
  71098. };
  71099. }
  71100. declare module BABYLON {
  71101. /** @hidden */
  71102. export var cellVertexShader: {
  71103. name: string;
  71104. shader: string;
  71105. };
  71106. }
  71107. declare module BABYLON {
  71108. export class CellMaterial extends BABYLON.PushMaterial {
  71109. private _diffuseTexture;
  71110. diffuseTexture: BABYLON.BaseTexture;
  71111. diffuseColor: BABYLON.Color3;
  71112. _computeHighLevel: boolean;
  71113. computeHighLevel: boolean;
  71114. private _disableLighting;
  71115. disableLighting: boolean;
  71116. private _maxSimultaneousLights;
  71117. maxSimultaneousLights: number;
  71118. private _renderId;
  71119. constructor(name: string, scene: BABYLON.Scene);
  71120. needAlphaBlending(): boolean;
  71121. needAlphaTesting(): boolean;
  71122. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71123. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71124. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71125. getAnimatables(): BABYLON.IAnimatable[];
  71126. getActiveTextures(): BABYLON.BaseTexture[];
  71127. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71128. dispose(forceDisposeEffect?: boolean): void;
  71129. getClassName(): string;
  71130. clone(name: string): CellMaterial;
  71131. serialize(): any;
  71132. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  71133. }
  71134. }
  71135. declare module BABYLON {
  71136. export class CustomShaderStructure {
  71137. FragmentStore: string;
  71138. VertexStore: string;
  71139. constructor();
  71140. }
  71141. export class ShaderSpecialParts {
  71142. constructor();
  71143. Fragment_Begin: string;
  71144. Fragment_Definitions: string;
  71145. Fragment_MainBegin: string;
  71146. Fragment_Custom_Diffuse: string;
  71147. Fragment_Before_Lights: string;
  71148. Fragment_Before_Fog: string;
  71149. Fragment_Custom_Alpha: string;
  71150. Fragment_Before_FragColor: string;
  71151. Vertex_Begin: string;
  71152. Vertex_Definitions: string;
  71153. Vertex_MainBegin: string;
  71154. Vertex_Before_PositionUpdated: string;
  71155. Vertex_Before_NormalUpdated: string;
  71156. Vertex_MainEnd: string;
  71157. }
  71158. export class CustomMaterial extends BABYLON.StandardMaterial {
  71159. static ShaderIndexer: number;
  71160. CustomParts: ShaderSpecialParts;
  71161. _isCreatedShader: boolean;
  71162. _createdShaderName: string;
  71163. _customUniform: string[];
  71164. _newUniforms: string[];
  71165. _newUniformInstances: any[];
  71166. _newSamplerInstances: BABYLON.Texture[];
  71167. FragmentShader: string;
  71168. VertexShader: string;
  71169. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71170. ReviewUniform(name: string, arr: string[]): string[];
  71171. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  71172. constructor(name: string, scene: BABYLON.Scene);
  71173. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  71174. Fragment_Begin(shaderPart: string): CustomMaterial;
  71175. Fragment_Definitions(shaderPart: string): CustomMaterial;
  71176. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  71177. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  71178. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  71179. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  71180. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  71181. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  71182. Vertex_Begin(shaderPart: string): CustomMaterial;
  71183. Vertex_Definitions(shaderPart: string): CustomMaterial;
  71184. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  71185. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  71186. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  71187. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  71188. }
  71189. }
  71190. declare module BABYLON {
  71191. export class ShaderAlebdoParts {
  71192. constructor();
  71193. Fragment_Begin: string;
  71194. Fragment_Definitions: string;
  71195. Fragment_MainBegin: string;
  71196. Fragment_Custom_Albedo: string;
  71197. Fragment_Before_Lights: string;
  71198. Fragment_Custom_MetallicRoughness: string;
  71199. Fragment_Custom_MicroSurface: string;
  71200. Fragment_Before_Fog: string;
  71201. Fragment_Custom_Alpha: string;
  71202. Fragment_Before_FragColor: string;
  71203. Vertex_Begin: string;
  71204. Vertex_Definitions: string;
  71205. Vertex_MainBegin: string;
  71206. Vertex_Before_PositionUpdated: string;
  71207. Vertex_Before_NormalUpdated: string;
  71208. Vertex_MainEnd: string;
  71209. }
  71210. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  71211. static ShaderIndexer: number;
  71212. CustomParts: ShaderAlebdoParts;
  71213. _isCreatedShader: boolean;
  71214. _createdShaderName: string;
  71215. _customUniform: string[];
  71216. _newUniforms: string[];
  71217. _newUniformInstances: any[];
  71218. _newSamplerInstances: BABYLON.Texture[];
  71219. FragmentShader: string;
  71220. VertexShader: string;
  71221. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  71222. ReviewUniform(name: string, arr: string[]): string[];
  71223. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  71224. constructor(name: string, scene: BABYLON.Scene);
  71225. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  71226. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  71227. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  71228. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  71229. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  71230. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  71231. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  71232. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  71233. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  71234. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  71235. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  71236. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  71237. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  71238. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  71239. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  71240. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  71241. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  71242. }
  71243. }
  71244. declare module BABYLON {
  71245. /** @hidden */
  71246. export var firePixelShader: {
  71247. name: string;
  71248. shader: string;
  71249. };
  71250. }
  71251. declare module BABYLON {
  71252. /** @hidden */
  71253. export var fireVertexShader: {
  71254. name: string;
  71255. shader: string;
  71256. };
  71257. }
  71258. declare module BABYLON {
  71259. export class FireMaterial extends BABYLON.PushMaterial {
  71260. private _diffuseTexture;
  71261. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71262. private _distortionTexture;
  71263. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71264. private _opacityTexture;
  71265. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  71266. diffuseColor: BABYLON.Color3;
  71267. speed: number;
  71268. private _scaledDiffuse;
  71269. private _renderId;
  71270. private _lastTime;
  71271. constructor(name: string, scene: BABYLON.Scene);
  71272. needAlphaBlending(): boolean;
  71273. needAlphaTesting(): boolean;
  71274. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71275. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71276. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71277. getAnimatables(): BABYLON.IAnimatable[];
  71278. getActiveTextures(): BABYLON.BaseTexture[];
  71279. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71280. getClassName(): string;
  71281. dispose(forceDisposeEffect?: boolean): void;
  71282. clone(name: string): FireMaterial;
  71283. serialize(): any;
  71284. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  71285. }
  71286. }
  71287. declare module BABYLON {
  71288. /** @hidden */
  71289. export var furPixelShader: {
  71290. name: string;
  71291. shader: string;
  71292. };
  71293. }
  71294. declare module BABYLON {
  71295. /** @hidden */
  71296. export var furVertexShader: {
  71297. name: string;
  71298. shader: string;
  71299. };
  71300. }
  71301. declare module BABYLON {
  71302. export class FurMaterial extends BABYLON.PushMaterial {
  71303. private _diffuseTexture;
  71304. diffuseTexture: BABYLON.BaseTexture;
  71305. private _heightTexture;
  71306. heightTexture: BABYLON.BaseTexture;
  71307. diffuseColor: BABYLON.Color3;
  71308. furLength: number;
  71309. furAngle: number;
  71310. furColor: BABYLON.Color3;
  71311. furOffset: number;
  71312. furSpacing: number;
  71313. furGravity: BABYLON.Vector3;
  71314. furSpeed: number;
  71315. furDensity: number;
  71316. furOcclusion: number;
  71317. furTexture: BABYLON.DynamicTexture;
  71318. private _disableLighting;
  71319. disableLighting: boolean;
  71320. private _maxSimultaneousLights;
  71321. maxSimultaneousLights: number;
  71322. highLevelFur: boolean;
  71323. _meshes: BABYLON.AbstractMesh[];
  71324. private _renderId;
  71325. private _furTime;
  71326. constructor(name: string, scene: BABYLON.Scene);
  71327. furTime: number;
  71328. needAlphaBlending(): boolean;
  71329. needAlphaTesting(): boolean;
  71330. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71331. updateFur(): void;
  71332. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71333. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71334. getAnimatables(): BABYLON.IAnimatable[];
  71335. getActiveTextures(): BABYLON.BaseTexture[];
  71336. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71337. dispose(forceDisposeEffect?: boolean): void;
  71338. clone(name: string): FurMaterial;
  71339. serialize(): any;
  71340. getClassName(): string;
  71341. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  71342. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  71343. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. /** @hidden */
  71348. export var gradientPixelShader: {
  71349. name: string;
  71350. shader: string;
  71351. };
  71352. }
  71353. declare module BABYLON {
  71354. /** @hidden */
  71355. export var gradientVertexShader: {
  71356. name: string;
  71357. shader: string;
  71358. };
  71359. }
  71360. declare module BABYLON {
  71361. export class GradientMaterial extends BABYLON.PushMaterial {
  71362. private _maxSimultaneousLights;
  71363. maxSimultaneousLights: number;
  71364. topColor: BABYLON.Color3;
  71365. topColorAlpha: number;
  71366. bottomColor: BABYLON.Color3;
  71367. bottomColorAlpha: number;
  71368. offset: number;
  71369. scale: number;
  71370. smoothness: number;
  71371. private _disableLighting;
  71372. disableLighting: boolean;
  71373. private _renderId;
  71374. constructor(name: string, scene: BABYLON.Scene);
  71375. needAlphaBlending(): boolean;
  71376. needAlphaTesting(): boolean;
  71377. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71378. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71379. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71380. getAnimatables(): BABYLON.IAnimatable[];
  71381. dispose(forceDisposeEffect?: boolean): void;
  71382. clone(name: string): GradientMaterial;
  71383. serialize(): any;
  71384. getClassName(): string;
  71385. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  71386. }
  71387. }
  71388. declare module BABYLON {
  71389. /** @hidden */
  71390. export var gridPixelShader: {
  71391. name: string;
  71392. shader: string;
  71393. };
  71394. }
  71395. declare module BABYLON {
  71396. /** @hidden */
  71397. export var gridVertexShader: {
  71398. name: string;
  71399. shader: string;
  71400. };
  71401. }
  71402. declare module BABYLON {
  71403. /**
  71404. * The grid materials allows you to wrap any shape with a grid.
  71405. * Colors are customizable.
  71406. */
  71407. export class GridMaterial extends BABYLON.PushMaterial {
  71408. /**
  71409. * Main color of the grid (e.g. between lines)
  71410. */
  71411. mainColor: BABYLON.Color3;
  71412. /**
  71413. * Color of the grid lines.
  71414. */
  71415. lineColor: BABYLON.Color3;
  71416. /**
  71417. * The scale of the grid compared to unit.
  71418. */
  71419. gridRatio: number;
  71420. /**
  71421. * Allows setting an offset for the grid lines.
  71422. */
  71423. gridOffset: BABYLON.Vector3;
  71424. /**
  71425. * The frequency of thicker lines.
  71426. */
  71427. majorUnitFrequency: number;
  71428. /**
  71429. * The visibility of minor units in the grid.
  71430. */
  71431. minorUnitVisibility: number;
  71432. /**
  71433. * The grid opacity outside of the lines.
  71434. */
  71435. opacity: number;
  71436. /**
  71437. * Determine RBG output is premultiplied by alpha value.
  71438. */
  71439. preMultiplyAlpha: boolean;
  71440. private _opacityTexture;
  71441. opacityTexture: BABYLON.BaseTexture;
  71442. private _gridControl;
  71443. private _renderId;
  71444. /**
  71445. * constructor
  71446. * @param name The name given to the material in order to identify it afterwards.
  71447. * @param scene The scene the material is used in.
  71448. */
  71449. constructor(name: string, scene: BABYLON.Scene);
  71450. /**
  71451. * Returns wehter or not the grid requires alpha blending.
  71452. */
  71453. needAlphaBlending(): boolean;
  71454. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71455. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71456. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71457. /**
  71458. * Dispose the material and its associated resources.
  71459. * @param forceDisposeEffect will also dispose the used effect when true
  71460. */
  71461. dispose(forceDisposeEffect?: boolean): void;
  71462. clone(name: string): GridMaterial;
  71463. serialize(): any;
  71464. getClassName(): string;
  71465. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  71466. }
  71467. }
  71468. declare module BABYLON {
  71469. /** @hidden */
  71470. export var lavaPixelShader: {
  71471. name: string;
  71472. shader: string;
  71473. };
  71474. }
  71475. declare module BABYLON {
  71476. /** @hidden */
  71477. export var lavaVertexShader: {
  71478. name: string;
  71479. shader: string;
  71480. };
  71481. }
  71482. declare module BABYLON {
  71483. export class LavaMaterial extends BABYLON.PushMaterial {
  71484. private _diffuseTexture;
  71485. diffuseTexture: BABYLON.BaseTexture;
  71486. noiseTexture: BABYLON.BaseTexture;
  71487. fogColor: BABYLON.Color3;
  71488. speed: number;
  71489. movingSpeed: number;
  71490. lowFrequencySpeed: number;
  71491. fogDensity: number;
  71492. private _lastTime;
  71493. diffuseColor: BABYLON.Color3;
  71494. private _disableLighting;
  71495. disableLighting: boolean;
  71496. private _unlit;
  71497. unlit: boolean;
  71498. private _maxSimultaneousLights;
  71499. maxSimultaneousLights: number;
  71500. private _scaledDiffuse;
  71501. private _renderId;
  71502. constructor(name: string, scene: BABYLON.Scene);
  71503. needAlphaBlending(): boolean;
  71504. needAlphaTesting(): boolean;
  71505. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71506. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71507. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71508. getAnimatables(): BABYLON.IAnimatable[];
  71509. getActiveTextures(): BABYLON.BaseTexture[];
  71510. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71511. dispose(forceDisposeEffect?: boolean): void;
  71512. clone(name: string): LavaMaterial;
  71513. serialize(): any;
  71514. getClassName(): string;
  71515. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  71516. }
  71517. }
  71518. declare module BABYLON {
  71519. /** @hidden */
  71520. export var mixPixelShader: {
  71521. name: string;
  71522. shader: string;
  71523. };
  71524. }
  71525. declare module BABYLON {
  71526. /** @hidden */
  71527. export var mixVertexShader: {
  71528. name: string;
  71529. shader: string;
  71530. };
  71531. }
  71532. declare module BABYLON {
  71533. export class MixMaterial extends BABYLON.PushMaterial {
  71534. /**
  71535. * Mix textures
  71536. */
  71537. private _mixTexture1;
  71538. mixTexture1: BABYLON.BaseTexture;
  71539. private _mixTexture2;
  71540. mixTexture2: BABYLON.BaseTexture;
  71541. /**
  71542. * Diffuse textures
  71543. */
  71544. private _diffuseTexture1;
  71545. diffuseTexture1: BABYLON.Texture;
  71546. private _diffuseTexture2;
  71547. diffuseTexture2: BABYLON.Texture;
  71548. private _diffuseTexture3;
  71549. diffuseTexture3: BABYLON.Texture;
  71550. private _diffuseTexture4;
  71551. diffuseTexture4: BABYLON.Texture;
  71552. private _diffuseTexture5;
  71553. diffuseTexture5: BABYLON.Texture;
  71554. private _diffuseTexture6;
  71555. diffuseTexture6: BABYLON.Texture;
  71556. private _diffuseTexture7;
  71557. diffuseTexture7: BABYLON.Texture;
  71558. private _diffuseTexture8;
  71559. diffuseTexture8: BABYLON.Texture;
  71560. /**
  71561. * Uniforms
  71562. */
  71563. diffuseColor: BABYLON.Color3;
  71564. specularColor: BABYLON.Color3;
  71565. specularPower: number;
  71566. private _disableLighting;
  71567. disableLighting: boolean;
  71568. private _maxSimultaneousLights;
  71569. maxSimultaneousLights: number;
  71570. private _renderId;
  71571. constructor(name: string, scene: BABYLON.Scene);
  71572. needAlphaBlending(): boolean;
  71573. needAlphaTesting(): boolean;
  71574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71577. getAnimatables(): BABYLON.IAnimatable[];
  71578. getActiveTextures(): BABYLON.BaseTexture[];
  71579. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71580. dispose(forceDisposeEffect?: boolean): void;
  71581. clone(name: string): MixMaterial;
  71582. serialize(): any;
  71583. getClassName(): string;
  71584. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  71585. }
  71586. }
  71587. declare module BABYLON {
  71588. /** @hidden */
  71589. export var normalPixelShader: {
  71590. name: string;
  71591. shader: string;
  71592. };
  71593. }
  71594. declare module BABYLON {
  71595. /** @hidden */
  71596. export var normalVertexShader: {
  71597. name: string;
  71598. shader: string;
  71599. };
  71600. }
  71601. declare module BABYLON {
  71602. export class NormalMaterial extends BABYLON.PushMaterial {
  71603. private _diffuseTexture;
  71604. diffuseTexture: BABYLON.BaseTexture;
  71605. diffuseColor: BABYLON.Color3;
  71606. private _disableLighting;
  71607. disableLighting: boolean;
  71608. private _maxSimultaneousLights;
  71609. maxSimultaneousLights: number;
  71610. private _renderId;
  71611. constructor(name: string, scene: BABYLON.Scene);
  71612. needAlphaBlending(): boolean;
  71613. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  71614. needAlphaTesting(): boolean;
  71615. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71616. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71617. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71618. getAnimatables(): BABYLON.IAnimatable[];
  71619. getActiveTextures(): BABYLON.BaseTexture[];
  71620. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71621. dispose(forceDisposeEffect?: boolean): void;
  71622. clone(name: string): NormalMaterial;
  71623. serialize(): any;
  71624. getClassName(): string;
  71625. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  71626. }
  71627. }
  71628. declare module BABYLON {
  71629. /** @hidden */
  71630. export var shadowOnlyPixelShader: {
  71631. name: string;
  71632. shader: string;
  71633. };
  71634. }
  71635. declare module BABYLON {
  71636. /** @hidden */
  71637. export var shadowOnlyVertexShader: {
  71638. name: string;
  71639. shader: string;
  71640. };
  71641. }
  71642. declare module BABYLON {
  71643. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  71644. private _renderId;
  71645. private _activeLight;
  71646. constructor(name: string, scene: BABYLON.Scene);
  71647. shadowColor: BABYLON.Color3;
  71648. needAlphaBlending(): boolean;
  71649. needAlphaTesting(): boolean;
  71650. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71651. activeLight: BABYLON.IShadowLight;
  71652. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71653. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71654. clone(name: string): ShadowOnlyMaterial;
  71655. serialize(): any;
  71656. getClassName(): string;
  71657. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  71658. }
  71659. }
  71660. declare module BABYLON {
  71661. /** @hidden */
  71662. export var simplePixelShader: {
  71663. name: string;
  71664. shader: string;
  71665. };
  71666. }
  71667. declare module BABYLON {
  71668. /** @hidden */
  71669. export var simpleVertexShader: {
  71670. name: string;
  71671. shader: string;
  71672. };
  71673. }
  71674. declare module BABYLON {
  71675. export class SimpleMaterial extends BABYLON.PushMaterial {
  71676. private _diffuseTexture;
  71677. diffuseTexture: BABYLON.BaseTexture;
  71678. diffuseColor: BABYLON.Color3;
  71679. private _disableLighting;
  71680. disableLighting: boolean;
  71681. private _maxSimultaneousLights;
  71682. maxSimultaneousLights: number;
  71683. private _renderId;
  71684. constructor(name: string, scene: BABYLON.Scene);
  71685. needAlphaBlending(): boolean;
  71686. needAlphaTesting(): boolean;
  71687. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71688. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71689. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71690. getAnimatables(): BABYLON.IAnimatable[];
  71691. getActiveTextures(): BABYLON.BaseTexture[];
  71692. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71693. dispose(forceDisposeEffect?: boolean): void;
  71694. clone(name: string): SimpleMaterial;
  71695. serialize(): any;
  71696. getClassName(): string;
  71697. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  71698. }
  71699. }
  71700. declare module BABYLON {
  71701. /** @hidden */
  71702. export var skyPixelShader: {
  71703. name: string;
  71704. shader: string;
  71705. };
  71706. }
  71707. declare module BABYLON {
  71708. /** @hidden */
  71709. export var skyVertexShader: {
  71710. name: string;
  71711. shader: string;
  71712. };
  71713. }
  71714. declare module BABYLON {
  71715. /**
  71716. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71717. * @see https://doc.babylonjs.com/extensions/sky
  71718. */
  71719. export class SkyMaterial extends BABYLON.PushMaterial {
  71720. /**
  71721. * Defines the overall luminance of sky in interval ]0, 1[.
  71722. */
  71723. luminance: number;
  71724. /**
  71725. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71726. */
  71727. turbidity: number;
  71728. /**
  71729. * Defines the sky appearance (light intensity).
  71730. */
  71731. rayleigh: number;
  71732. /**
  71733. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71734. */
  71735. mieCoefficient: number;
  71736. /**
  71737. * Defines the amount of haze particles following the Mie scattering theory.
  71738. */
  71739. mieDirectionalG: number;
  71740. /**
  71741. * Defines the distance of the sun according to the active scene camera.
  71742. */
  71743. distance: number;
  71744. /**
  71745. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71746. * "inclined".
  71747. */
  71748. inclination: number;
  71749. /**
  71750. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71751. * an object direction and a reference direction.
  71752. */
  71753. azimuth: number;
  71754. /**
  71755. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71756. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71757. */
  71758. sunPosition: BABYLON.Vector3;
  71759. /**
  71760. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71761. * .sunPosition property.
  71762. */
  71763. useSunPosition: boolean;
  71764. /**
  71765. * Defines an offset vector used to get a horizon offset.
  71766. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71767. */
  71768. cameraOffset: BABYLON.Vector3;
  71769. private _cameraPosition;
  71770. private _renderId;
  71771. /**
  71772. * Instantiates a new sky material.
  71773. * This material allows to create dynamic and texture free
  71774. * effects for skyboxes by taking care of the atmosphere state.
  71775. * @see https://doc.babylonjs.com/extensions/sky
  71776. * @param name Define the name of the material in the scene
  71777. * @param scene Define the scene the material belong to
  71778. */
  71779. constructor(name: string, scene: BABYLON.Scene);
  71780. /**
  71781. * Specifies if the material will require alpha blending
  71782. * @returns a boolean specifying if alpha blending is needed
  71783. */
  71784. needAlphaBlending(): boolean;
  71785. /**
  71786. * Specifies if this material should be rendered in alpha test mode
  71787. * @returns false as the sky material doesn't need alpha testing.
  71788. */
  71789. needAlphaTesting(): boolean;
  71790. /**
  71791. * Get the texture used for alpha test purpose.
  71792. * @returns null as the sky material has no texture.
  71793. */
  71794. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71795. /**
  71796. * Get if the submesh is ready to be used and all its information available.
  71797. * Child classes can use it to update shaders
  71798. * @param mesh defines the mesh to check
  71799. * @param subMesh defines which submesh to check
  71800. * @param useInstances specifies that instances should be used
  71801. * @returns a boolean indicating that the submesh is ready or not
  71802. */
  71803. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71804. /**
  71805. * Binds the submesh to this material by preparing the effect and shader to draw
  71806. * @param world defines the world transformation matrix
  71807. * @param mesh defines the mesh containing the submesh
  71808. * @param subMesh defines the submesh to bind the material to
  71809. */
  71810. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71811. /**
  71812. * Get the list of animatables in the material.
  71813. * @returns the list of animatables object used in the material
  71814. */
  71815. getAnimatables(): BABYLON.IAnimatable[];
  71816. /**
  71817. * Disposes the material
  71818. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71819. */
  71820. dispose(forceDisposeEffect?: boolean): void;
  71821. /**
  71822. * Makes a duplicate of the material, and gives it a new name
  71823. * @param name defines the new name for the duplicated material
  71824. * @returns the cloned material
  71825. */
  71826. clone(name: string): SkyMaterial;
  71827. /**
  71828. * Serializes this material in a JSON representation
  71829. * @returns the serialized material object
  71830. */
  71831. serialize(): any;
  71832. /**
  71833. * Gets the current class name of the material e.g. "SkyMaterial"
  71834. * Mainly use in serialization.
  71835. * @returns the class name
  71836. */
  71837. getClassName(): string;
  71838. /**
  71839. * Creates a sky material from parsed material data
  71840. * @param source defines the JSON representation of the material
  71841. * @param scene defines the hosting scene
  71842. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71843. * @returns a new sky material
  71844. */
  71845. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71846. }
  71847. }
  71848. declare module BABYLON {
  71849. /** @hidden */
  71850. export var terrainPixelShader: {
  71851. name: string;
  71852. shader: string;
  71853. };
  71854. }
  71855. declare module BABYLON {
  71856. /** @hidden */
  71857. export var terrainVertexShader: {
  71858. name: string;
  71859. shader: string;
  71860. };
  71861. }
  71862. declare module BABYLON {
  71863. export class TerrainMaterial extends BABYLON.PushMaterial {
  71864. private _mixTexture;
  71865. mixTexture: BABYLON.BaseTexture;
  71866. private _diffuseTexture1;
  71867. diffuseTexture1: BABYLON.Texture;
  71868. private _diffuseTexture2;
  71869. diffuseTexture2: BABYLON.Texture;
  71870. private _diffuseTexture3;
  71871. diffuseTexture3: BABYLON.Texture;
  71872. private _bumpTexture1;
  71873. bumpTexture1: BABYLON.Texture;
  71874. private _bumpTexture2;
  71875. bumpTexture2: BABYLON.Texture;
  71876. private _bumpTexture3;
  71877. bumpTexture3: BABYLON.Texture;
  71878. diffuseColor: BABYLON.Color3;
  71879. specularColor: BABYLON.Color3;
  71880. specularPower: number;
  71881. private _disableLighting;
  71882. disableLighting: boolean;
  71883. private _maxSimultaneousLights;
  71884. maxSimultaneousLights: number;
  71885. private _renderId;
  71886. constructor(name: string, scene: BABYLON.Scene);
  71887. needAlphaBlending(): boolean;
  71888. needAlphaTesting(): boolean;
  71889. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71890. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71891. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71892. getAnimatables(): BABYLON.IAnimatable[];
  71893. getActiveTextures(): BABYLON.BaseTexture[];
  71894. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71895. dispose(forceDisposeEffect?: boolean): void;
  71896. clone(name: string): TerrainMaterial;
  71897. serialize(): any;
  71898. getClassName(): string;
  71899. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71900. }
  71901. }
  71902. declare module BABYLON {
  71903. /** @hidden */
  71904. export var triplanarPixelShader: {
  71905. name: string;
  71906. shader: string;
  71907. };
  71908. }
  71909. declare module BABYLON {
  71910. /** @hidden */
  71911. export var triplanarVertexShader: {
  71912. name: string;
  71913. shader: string;
  71914. };
  71915. }
  71916. declare module BABYLON {
  71917. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71918. mixTexture: BABYLON.BaseTexture;
  71919. private _diffuseTextureX;
  71920. diffuseTextureX: BABYLON.BaseTexture;
  71921. private _diffuseTextureY;
  71922. diffuseTextureY: BABYLON.BaseTexture;
  71923. private _diffuseTextureZ;
  71924. diffuseTextureZ: BABYLON.BaseTexture;
  71925. private _normalTextureX;
  71926. normalTextureX: BABYLON.BaseTexture;
  71927. private _normalTextureY;
  71928. normalTextureY: BABYLON.BaseTexture;
  71929. private _normalTextureZ;
  71930. normalTextureZ: BABYLON.BaseTexture;
  71931. tileSize: number;
  71932. diffuseColor: BABYLON.Color3;
  71933. specularColor: BABYLON.Color3;
  71934. specularPower: number;
  71935. private _disableLighting;
  71936. disableLighting: boolean;
  71937. private _maxSimultaneousLights;
  71938. maxSimultaneousLights: number;
  71939. private _renderId;
  71940. constructor(name: string, scene: BABYLON.Scene);
  71941. needAlphaBlending(): boolean;
  71942. needAlphaTesting(): boolean;
  71943. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71944. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71945. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71946. getAnimatables(): BABYLON.IAnimatable[];
  71947. getActiveTextures(): BABYLON.BaseTexture[];
  71948. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71949. dispose(forceDisposeEffect?: boolean): void;
  71950. clone(name: string): TriPlanarMaterial;
  71951. serialize(): any;
  71952. getClassName(): string;
  71953. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71954. }
  71955. }
  71956. declare module BABYLON {
  71957. /** @hidden */
  71958. export var waterPixelShader: {
  71959. name: string;
  71960. shader: string;
  71961. };
  71962. }
  71963. declare module BABYLON {
  71964. /** @hidden */
  71965. export var waterVertexShader: {
  71966. name: string;
  71967. shader: string;
  71968. };
  71969. }
  71970. declare module BABYLON {
  71971. export class WaterMaterial extends BABYLON.PushMaterial {
  71972. renderTargetSize: BABYLON.Vector2;
  71973. private _bumpTexture;
  71974. bumpTexture: BABYLON.BaseTexture;
  71975. diffuseColor: BABYLON.Color3;
  71976. specularColor: BABYLON.Color3;
  71977. specularPower: number;
  71978. private _disableLighting;
  71979. disableLighting: boolean;
  71980. private _maxSimultaneousLights;
  71981. maxSimultaneousLights: number;
  71982. /**
  71983. * @param {number}: Represents the wind force
  71984. */
  71985. windForce: number;
  71986. /**
  71987. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71988. */
  71989. windDirection: BABYLON.Vector2;
  71990. /**
  71991. * @param {number}: Wave height, represents the height of the waves
  71992. */
  71993. waveHeight: number;
  71994. /**
  71995. * @param {number}: Bump height, represents the bump height related to the bump map
  71996. */
  71997. bumpHeight: number;
  71998. /**
  71999. * @param {boolean}: Add a smaller moving bump to less steady waves.
  72000. */
  72001. private _bumpSuperimpose;
  72002. bumpSuperimpose: boolean;
  72003. /**
  72004. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  72005. */
  72006. private _fresnelSeparate;
  72007. fresnelSeparate: boolean;
  72008. /**
  72009. * @param {boolean}: bump Waves modify the reflection.
  72010. */
  72011. private _bumpAffectsReflection;
  72012. bumpAffectsReflection: boolean;
  72013. /**
  72014. * @param {number}: The water color blended with the refraction (near)
  72015. */
  72016. waterColor: BABYLON.Color3;
  72017. /**
  72018. * @param {number}: The blend factor related to the water color
  72019. */
  72020. colorBlendFactor: number;
  72021. /**
  72022. * @param {number}: The water color blended with the reflection (far)
  72023. */
  72024. waterColor2: BABYLON.Color3;
  72025. /**
  72026. * @param {number}: The blend factor related to the water color (reflection, far)
  72027. */
  72028. colorBlendFactor2: number;
  72029. /**
  72030. * @param {number}: Represents the maximum length of a wave
  72031. */
  72032. waveLength: number;
  72033. /**
  72034. * @param {number}: Defines the waves speed
  72035. */
  72036. waveSpeed: number;
  72037. /**
  72038. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  72039. * will avoid calculating useless pixels in the pixel shader of the water material.
  72040. */
  72041. disableClipPlane: boolean;
  72042. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  72043. private _mesh;
  72044. private _refractionRTT;
  72045. private _reflectionRTT;
  72046. private _reflectionTransform;
  72047. private _lastTime;
  72048. private _lastDeltaTime;
  72049. private _renderId;
  72050. private _useLogarithmicDepth;
  72051. private _waitingRenderList;
  72052. private _imageProcessingConfiguration;
  72053. private _imageProcessingObserver;
  72054. /**
  72055. * Gets a boolean indicating that current material needs to register RTT
  72056. */
  72057. readonly hasRenderTargetTextures: boolean;
  72058. /**
  72059. * Constructor
  72060. */
  72061. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  72062. useLogarithmicDepth: boolean;
  72063. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72064. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  72065. addToRenderList(node: any): void;
  72066. enableRenderTargets(enable: boolean): void;
  72067. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  72068. readonly renderTargetsEnabled: boolean;
  72069. needAlphaBlending(): boolean;
  72070. needAlphaTesting(): boolean;
  72071. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  72072. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  72073. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  72074. private _createRenderTargets;
  72075. getAnimatables(): BABYLON.IAnimatable[];
  72076. getActiveTextures(): BABYLON.BaseTexture[];
  72077. hasTexture(texture: BABYLON.BaseTexture): boolean;
  72078. dispose(forceDisposeEffect?: boolean): void;
  72079. clone(name: string): WaterMaterial;
  72080. serialize(): any;
  72081. getClassName(): string;
  72082. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  72083. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  72084. }
  72085. }
  72086. declare module BABYLON {
  72087. /** @hidden */
  72088. export var asciiartPixelShader: {
  72089. name: string;
  72090. shader: string;
  72091. };
  72092. }
  72093. declare module BABYLON {
  72094. /**
  72095. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  72096. *
  72097. * It basically takes care rendering the font front the given font size to a texture.
  72098. * This is used later on in the postprocess.
  72099. */
  72100. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  72101. private _font;
  72102. private _text;
  72103. private _charSize;
  72104. /**
  72105. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72106. */
  72107. readonly charSize: number;
  72108. /**
  72109. * Create a new instance of the Ascii Art FontTexture class
  72110. * @param name the name of the texture
  72111. * @param font the font to use, use the W3C CSS notation
  72112. * @param text the caracter set to use in the rendering.
  72113. * @param scene the scene that owns the texture
  72114. */
  72115. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72116. /**
  72117. * Gets the max char width of a font.
  72118. * @param font the font to use, use the W3C CSS notation
  72119. * @return the max char width
  72120. */
  72121. private getFontWidth;
  72122. /**
  72123. * Gets the max char height of a font.
  72124. * @param font the font to use, use the W3C CSS notation
  72125. * @return the max char height
  72126. */
  72127. private getFontHeight;
  72128. /**
  72129. * Clones the current AsciiArtTexture.
  72130. * @return the clone of the texture.
  72131. */
  72132. clone(): AsciiArtFontTexture;
  72133. /**
  72134. * Parses a json object representing the texture and returns an instance of it.
  72135. * @param source the source JSON representation
  72136. * @param scene the scene to create the texture for
  72137. * @return the parsed texture
  72138. */
  72139. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  72140. }
  72141. /**
  72142. * Option available in the Ascii Art Post Process.
  72143. */
  72144. export interface IAsciiArtPostProcessOptions {
  72145. /**
  72146. * The font to use following the w3c font definition.
  72147. */
  72148. font?: string;
  72149. /**
  72150. * The character set to use in the postprocess.
  72151. */
  72152. characterSet?: string;
  72153. /**
  72154. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72155. * This number is defined between 0 and 1;
  72156. */
  72157. mixToTile?: number;
  72158. /**
  72159. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72160. * This number is defined between 0 and 1;
  72161. */
  72162. mixToNormal?: number;
  72163. }
  72164. /**
  72165. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  72166. *
  72167. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72168. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  72169. */
  72170. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  72171. /**
  72172. * The font texture used to render the char in the post process.
  72173. */
  72174. private _asciiArtFontTexture;
  72175. /**
  72176. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  72177. * This number is defined between 0 and 1;
  72178. */
  72179. mixToTile: number;
  72180. /**
  72181. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  72182. * This number is defined between 0 and 1;
  72183. */
  72184. mixToNormal: number;
  72185. /**
  72186. * Instantiates a new Ascii Art Post Process.
  72187. * @param name the name to give to the postprocess
  72188. * @camera the camera to apply the post process to.
  72189. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  72190. */
  72191. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  72192. }
  72193. }
  72194. declare module BABYLON {
  72195. /** @hidden */
  72196. export var digitalrainPixelShader: {
  72197. name: string;
  72198. shader: string;
  72199. };
  72200. }
  72201. declare module BABYLON {
  72202. /**
  72203. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  72204. *
  72205. * It basically takes care rendering the font front the given font size to a texture.
  72206. * This is used later on in the postprocess.
  72207. */
  72208. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  72209. private _font;
  72210. private _text;
  72211. private _charSize;
  72212. /**
  72213. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  72214. */
  72215. readonly charSize: number;
  72216. /**
  72217. * Create a new instance of the Digital Rain FontTexture class
  72218. * @param name the name of the texture
  72219. * @param font the font to use, use the W3C CSS notation
  72220. * @param text the caracter set to use in the rendering.
  72221. * @param scene the scene that owns the texture
  72222. */
  72223. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  72224. /**
  72225. * Gets the max char width of a font.
  72226. * @param font the font to use, use the W3C CSS notation
  72227. * @return the max char width
  72228. */
  72229. private getFontWidth;
  72230. /**
  72231. * Gets the max char height of a font.
  72232. * @param font the font to use, use the W3C CSS notation
  72233. * @return the max char height
  72234. */
  72235. private getFontHeight;
  72236. /**
  72237. * Clones the current DigitalRainFontTexture.
  72238. * @return the clone of the texture.
  72239. */
  72240. clone(): DigitalRainFontTexture;
  72241. /**
  72242. * Parses a json object representing the texture and returns an instance of it.
  72243. * @param source the source JSON representation
  72244. * @param scene the scene to create the texture for
  72245. * @return the parsed texture
  72246. */
  72247. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  72248. }
  72249. /**
  72250. * Option available in the Digital Rain Post Process.
  72251. */
  72252. export interface IDigitalRainPostProcessOptions {
  72253. /**
  72254. * The font to use following the w3c font definition.
  72255. */
  72256. font?: string;
  72257. /**
  72258. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72259. * This number is defined between 0 and 1;
  72260. */
  72261. mixToTile?: number;
  72262. /**
  72263. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72264. * This number is defined between 0 and 1;
  72265. */
  72266. mixToNormal?: number;
  72267. }
  72268. /**
  72269. * DigitalRainPostProcess helps rendering everithing in digital rain.
  72270. *
  72271. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72272. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  72273. */
  72274. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  72275. /**
  72276. * The font texture used to render the char in the post process.
  72277. */
  72278. private _digitalRainFontTexture;
  72279. /**
  72280. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  72281. * This number is defined between 0 and 1;
  72282. */
  72283. mixToTile: number;
  72284. /**
  72285. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  72286. * This number is defined between 0 and 1;
  72287. */
  72288. mixToNormal: number;
  72289. /**
  72290. * Instantiates a new Digital Rain Post Process.
  72291. * @param name the name to give to the postprocess
  72292. * @camera the camera to apply the post process to.
  72293. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  72294. */
  72295. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  72296. }
  72297. }
  72298. declare module BABYLON {
  72299. /** @hidden */
  72300. export var oceanPostProcessPixelShader: {
  72301. name: string;
  72302. shader: string;
  72303. };
  72304. }
  72305. declare module BABYLON {
  72306. /**
  72307. * Option available in the Ocean Post Process.
  72308. */
  72309. export interface IOceanPostProcessOptions {
  72310. /**
  72311. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72312. */
  72313. reflectionSize?: number | {
  72314. width: number;
  72315. height: number;
  72316. } | {
  72317. ratio: number;
  72318. };
  72319. /**
  72320. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  72321. */
  72322. refractionSize?: number | {
  72323. width: number;
  72324. height: number;
  72325. } | {
  72326. ratio: number;
  72327. };
  72328. }
  72329. /**
  72330. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  72331. *
  72332. * Simmply add it to your scene and let the nerd that lives in you have fun.
  72333. * Example usage:
  72334. * var pp = new OceanPostProcess("myOcean", camera);
  72335. * pp.reflectionEnabled = true;
  72336. * pp.refractionEnabled = true;
  72337. */
  72338. export class OceanPostProcess extends BABYLON.PostProcess {
  72339. /**
  72340. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  72341. */
  72342. /**
  72343. * Sets weither or not the real-time reflection is enabled on the ocean.
  72344. * Is set to true, the reflection mirror texture will be used as reflection texture.
  72345. */
  72346. reflectionEnabled: boolean;
  72347. /**
  72348. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  72349. */
  72350. /**
  72351. * Sets weither or not the real-time refraction is enabled on the ocean.
  72352. * Is set to true, the refraction render target texture will be used as refraction texture.
  72353. */
  72354. refractionEnabled: boolean;
  72355. /**
  72356. * Gets wether or not the post-processes is supported by the running hardware.
  72357. * This requires draw buffer supports.
  72358. */
  72359. readonly isSupported: boolean;
  72360. /**
  72361. * This is the reflection mirror texture used to display reflections on the ocean.
  72362. * By default, render list is empty.
  72363. */
  72364. reflectionTexture: BABYLON.MirrorTexture;
  72365. /**
  72366. * This is the refraction render target texture used to display refraction on the ocean.
  72367. * By default, render list is empty.
  72368. */
  72369. refractionTexture: BABYLON.RenderTargetTexture;
  72370. private _time;
  72371. private _cameraRotation;
  72372. private _cameraViewMatrix;
  72373. private _reflectionEnabled;
  72374. private _refractionEnabled;
  72375. private _geometryRenderer;
  72376. /**
  72377. * Instantiates a new Ocean Post Process.
  72378. * @param name the name to give to the postprocess.
  72379. * @camera the camera to apply the post process to.
  72380. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  72381. */
  72382. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  72383. /**
  72384. * Returns the appropriate defines according to the current configuration.
  72385. */
  72386. private _getDefines;
  72387. /**
  72388. * Computes the current camera rotation as the shader requires a camera rotation.
  72389. */
  72390. private _computeCameraRotation;
  72391. }
  72392. }
  72393. declare module BABYLON {
  72394. /** @hidden */
  72395. export var brickProceduralTexturePixelShader: {
  72396. name: string;
  72397. shader: string;
  72398. };
  72399. }
  72400. declare module BABYLON {
  72401. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  72402. private _numberOfBricksHeight;
  72403. private _numberOfBricksWidth;
  72404. private _jointColor;
  72405. private _brickColor;
  72406. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72407. updateShaderUniforms(): void;
  72408. numberOfBricksHeight: number;
  72409. numberOfBricksWidth: number;
  72410. jointColor: BABYLON.Color3;
  72411. brickColor: BABYLON.Color3;
  72412. /**
  72413. * Serializes this brick procedural texture
  72414. * @returns a serialized brick procedural texture object
  72415. */
  72416. serialize(): any;
  72417. /**
  72418. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  72419. * @param parsedTexture defines parsed texture data
  72420. * @param scene defines the current scene
  72421. * @param rootUrl defines the root URL containing brick procedural texture information
  72422. * @returns a parsed Brick Procedural BABYLON.Texture
  72423. */
  72424. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  72425. }
  72426. }
  72427. declare module BABYLON {
  72428. /** @hidden */
  72429. export var cloudProceduralTexturePixelShader: {
  72430. name: string;
  72431. shader: string;
  72432. };
  72433. }
  72434. declare module BABYLON {
  72435. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  72436. private _skyColor;
  72437. private _cloudColor;
  72438. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72439. updateShaderUniforms(): void;
  72440. skyColor: BABYLON.Color4;
  72441. cloudColor: BABYLON.Color4;
  72442. /**
  72443. * Serializes this cloud procedural texture
  72444. * @returns a serialized cloud procedural texture object
  72445. */
  72446. serialize(): any;
  72447. /**
  72448. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  72449. * @param parsedTexture defines parsed texture data
  72450. * @param scene defines the current scene
  72451. * @param rootUrl defines the root URL containing cloud procedural texture information
  72452. * @returns a parsed Cloud Procedural BABYLON.Texture
  72453. */
  72454. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  72455. }
  72456. }
  72457. declare module BABYLON {
  72458. /** @hidden */
  72459. export var fireProceduralTexturePixelShader: {
  72460. name: string;
  72461. shader: string;
  72462. };
  72463. }
  72464. declare module BABYLON {
  72465. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  72466. private _time;
  72467. private _speed;
  72468. private _autoGenerateTime;
  72469. private _fireColors;
  72470. private _alphaThreshold;
  72471. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72472. updateShaderUniforms(): void;
  72473. render(useCameraPostProcess?: boolean): void;
  72474. static readonly PurpleFireColors: BABYLON.Color3[];
  72475. static readonly GreenFireColors: BABYLON.Color3[];
  72476. static readonly RedFireColors: BABYLON.Color3[];
  72477. static readonly BlueFireColors: BABYLON.Color3[];
  72478. autoGenerateTime: boolean;
  72479. fireColors: BABYLON.Color3[];
  72480. time: number;
  72481. speed: BABYLON.Vector2;
  72482. alphaThreshold: number;
  72483. /**
  72484. * Serializes this fire procedural texture
  72485. * @returns a serialized fire procedural texture object
  72486. */
  72487. serialize(): any;
  72488. /**
  72489. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  72490. * @param parsedTexture defines parsed texture data
  72491. * @param scene defines the current scene
  72492. * @param rootUrl defines the root URL containing fire procedural texture information
  72493. * @returns a parsed Fire Procedural BABYLON.Texture
  72494. */
  72495. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  72496. }
  72497. }
  72498. declare module BABYLON {
  72499. /** @hidden */
  72500. export var grassProceduralTexturePixelShader: {
  72501. name: string;
  72502. shader: string;
  72503. };
  72504. }
  72505. declare module BABYLON {
  72506. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  72507. private _grassColors;
  72508. private _groundColor;
  72509. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72510. updateShaderUniforms(): void;
  72511. grassColors: BABYLON.Color3[];
  72512. groundColor: BABYLON.Color3;
  72513. /**
  72514. * Serializes this grass procedural texture
  72515. * @returns a serialized grass procedural texture object
  72516. */
  72517. serialize(): any;
  72518. /**
  72519. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  72520. * @param parsedTexture defines parsed texture data
  72521. * @param scene defines the current scene
  72522. * @param rootUrl defines the root URL containing grass procedural texture information
  72523. * @returns a parsed Grass Procedural BABYLON.Texture
  72524. */
  72525. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  72526. }
  72527. }
  72528. declare module BABYLON {
  72529. /** @hidden */
  72530. export var marbleProceduralTexturePixelShader: {
  72531. name: string;
  72532. shader: string;
  72533. };
  72534. }
  72535. declare module BABYLON {
  72536. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  72537. private _numberOfTilesHeight;
  72538. private _numberOfTilesWidth;
  72539. private _amplitude;
  72540. private _jointColor;
  72541. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72542. updateShaderUniforms(): void;
  72543. numberOfTilesHeight: number;
  72544. amplitude: number;
  72545. numberOfTilesWidth: number;
  72546. jointColor: BABYLON.Color3;
  72547. /**
  72548. * Serializes this marble procedural texture
  72549. * @returns a serialized marble procedural texture object
  72550. */
  72551. serialize(): any;
  72552. /**
  72553. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  72554. * @param parsedTexture defines parsed texture data
  72555. * @param scene defines the current scene
  72556. * @param rootUrl defines the root URL containing marble procedural texture information
  72557. * @returns a parsed Marble Procedural BABYLON.Texture
  72558. */
  72559. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  72560. }
  72561. }
  72562. declare module BABYLON {
  72563. /** @hidden */
  72564. export var normalMapProceduralTexturePixelShader: {
  72565. name: string;
  72566. shader: string;
  72567. };
  72568. }
  72569. declare module BABYLON {
  72570. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  72571. private _baseTexture;
  72572. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72573. updateShaderUniforms(): void;
  72574. render(useCameraPostProcess?: boolean): void;
  72575. resize(size: any, generateMipMaps: any): void;
  72576. baseTexture: BABYLON.Texture;
  72577. /**
  72578. * Serializes this normal map procedural texture
  72579. * @returns a serialized normal map procedural texture object
  72580. */
  72581. serialize(): any;
  72582. /**
  72583. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  72584. * @param parsedTexture defines parsed texture data
  72585. * @param scene defines the current scene
  72586. * @param rootUrl defines the root URL containing normal map procedural texture information
  72587. * @returns a parsed Normal Map Procedural BABYLON.Texture
  72588. */
  72589. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  72590. }
  72591. }
  72592. declare module BABYLON {
  72593. /** @hidden */
  72594. export var perlinNoiseProceduralTexturePixelShader: {
  72595. name: string;
  72596. shader: string;
  72597. };
  72598. }
  72599. declare module BABYLON {
  72600. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  72601. time: number;
  72602. timeScale: number;
  72603. translationSpeed: number;
  72604. private _currentTranslation;
  72605. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72606. updateShaderUniforms(): void;
  72607. render(useCameraPostProcess?: boolean): void;
  72608. resize(size: any, generateMipMaps: any): void;
  72609. /**
  72610. * Serializes this perlin noise procedural texture
  72611. * @returns a serialized perlin noise procedural texture object
  72612. */
  72613. serialize(): any;
  72614. /**
  72615. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  72616. * @param parsedTexture defines parsed texture data
  72617. * @param scene defines the current scene
  72618. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  72619. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  72620. */
  72621. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  72622. }
  72623. }
  72624. declare module BABYLON {
  72625. /** @hidden */
  72626. export var roadProceduralTexturePixelShader: {
  72627. name: string;
  72628. shader: string;
  72629. };
  72630. }
  72631. declare module BABYLON {
  72632. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  72633. private _roadColor;
  72634. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72635. updateShaderUniforms(): void;
  72636. roadColor: BABYLON.Color3;
  72637. /**
  72638. * Serializes this road procedural texture
  72639. * @returns a serialized road procedural texture object
  72640. */
  72641. serialize(): any;
  72642. /**
  72643. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  72644. * @param parsedTexture defines parsed texture data
  72645. * @param scene defines the current scene
  72646. * @param rootUrl defines the root URL containing road procedural texture information
  72647. * @returns a parsed Road Procedural BABYLON.Texture
  72648. */
  72649. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  72650. }
  72651. }
  72652. declare module BABYLON {
  72653. /** @hidden */
  72654. export var starfieldProceduralTexturePixelShader: {
  72655. name: string;
  72656. shader: string;
  72657. };
  72658. }
  72659. declare module BABYLON {
  72660. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  72661. private _time;
  72662. private _alpha;
  72663. private _beta;
  72664. private _zoom;
  72665. private _formuparam;
  72666. private _stepsize;
  72667. private _tile;
  72668. private _brightness;
  72669. private _darkmatter;
  72670. private _distfading;
  72671. private _saturation;
  72672. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72673. updateShaderUniforms(): void;
  72674. time: number;
  72675. alpha: number;
  72676. beta: number;
  72677. formuparam: number;
  72678. stepsize: number;
  72679. zoom: number;
  72680. tile: number;
  72681. brightness: number;
  72682. darkmatter: number;
  72683. distfading: number;
  72684. saturation: number;
  72685. /**
  72686. * Serializes this starfield procedural texture
  72687. * @returns a serialized starfield procedural texture object
  72688. */
  72689. serialize(): any;
  72690. /**
  72691. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  72692. * @param parsedTexture defines parsed texture data
  72693. * @param scene defines the current scene
  72694. * @param rootUrl defines the root URL containing startfield procedural texture information
  72695. * @returns a parsed Starfield Procedural BABYLON.Texture
  72696. */
  72697. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  72698. }
  72699. }
  72700. declare module BABYLON {
  72701. /** @hidden */
  72702. export var woodProceduralTexturePixelShader: {
  72703. name: string;
  72704. shader: string;
  72705. };
  72706. }
  72707. declare module BABYLON {
  72708. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  72709. private _ampScale;
  72710. private _woodColor;
  72711. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  72712. updateShaderUniforms(): void;
  72713. ampScale: number;
  72714. woodColor: BABYLON.Color3;
  72715. /**
  72716. * Serializes this wood procedural texture
  72717. * @returns a serialized wood procedural texture object
  72718. */
  72719. serialize(): any;
  72720. /**
  72721. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72722. * @param parsedTexture defines parsed texture data
  72723. * @param scene defines the current scene
  72724. * @param rootUrl defines the root URL containing wood procedural texture information
  72725. * @returns a parsed Wood Procedural BABYLON.Texture
  72726. */
  72727. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72728. }
  72729. }